Sha256: 2bbd61936d46291c9818468968635a8aa304b167fc925fcdda7a4f84c854228c

Contents?: true

Size: 608 Bytes

Versions: 23

Compression:

Stored size: 608 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  # Reports errors when trying to use parser-blocking script tags
  class ParserBlockingScriptTag < LiquidCheck
    severity :error
    categories :liquid, :performance
    doc docs_url(__FILE__)

    def on_variable(node)
      used_filters = node.value.filters.map { |name, *_rest| name }
      if used_filters.include?("script_tag")
        add_offense(
          "The script_tag filter is parser-blocking. Use a script tag with the async or defer " \
          "attribute for better performance",
          node: node
        )
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
theme-check-1.9.2 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.9.1 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.9.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.8.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.7.2 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.7.1 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.7.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.6.2 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.6.1 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.6.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.5.2 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.5.1 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.5.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.4.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.3.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.2.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.1.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.0.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-0.10.2 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-0.10.1 lib/theme_check/checks/parser_blocking_script_tag.rb