Sha256: 58952de5b2ce123644fa7207c17d4921a65b625d5afc3ed912dd3ddd09c0c829

Contents?: true

Size: 602 Bytes

Versions: 10

Compression:

Stored size: 602 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.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

10 entries across 10 versions & 1 rubygems

Version Path
theme-check-1.15.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.14.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.13.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.12.1 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.12.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.11.0 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.10.3 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.10.2 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.10.1 lib/theme_check/checks/parser_blocking_script_tag.rb
theme-check-1.10.0 lib/theme_check/checks/parser_blocking_script_tag.rb