Sha256: 2dd1a525db2f937b91c0484a8f6c0ef95fd3e3315b6c05af276c4c172c9a1be5

Contents?: true

Size: 523 Bytes

Versions: 8

Compression:

Stored size: 523 Bytes

Contents

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

    def on_script(node)
      return unless node.attributes["src"]
      return if node.attributes["defer"] || node.attributes["async"] || node.attributes["type"]&.value == "module"

      add_offense("Missing async or defer attribute on script tag", node: node)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
theme-check-1.2.0 lib/theme_check/checks/parser_blocking_javascript.rb
theme-check-1.1.0 lib/theme_check/checks/parser_blocking_javascript.rb
theme-check-1.0.0 lib/theme_check/checks/parser_blocking_javascript.rb
theme-check-0.10.2 lib/theme_check/checks/parser_blocking_javascript.rb
theme-check-0.10.1 lib/theme_check/checks/parser_blocking_javascript.rb
theme-check-0.10.0 lib/theme_check/checks/parser_blocking_javascript.rb
theme-check-0.9.1 lib/theme_check/checks/parser_blocking_javascript.rb
theme-check-0.9.0 lib/theme_check/checks/parser_blocking_javascript.rb