Sha256: 31c339282836a7db949cb7e437c65acb8af31622a4ff4f3235ba48de68b95bd2

Contents?: true

Size: 596 Bytes

Versions: 24

Compression:

Stored size: 596 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  class ImgLazyLoading < HtmlCheck
    severity :suggestion
    categories :html, :performance
    doc docs_url(__FILE__)

    ACCEPTED_LOADING_VALUES = %w[lazy eager]

    def on_img(node)
      loading = node.attributes["loading"]&.downcase
      return if ACCEPTED_LOADING_VALUES.include?(loading)
      if loading == "auto"
        add_offense("Prefer loading=\"lazy\" to defer loading of images", node: node)
      else
        add_offense("Add a loading=\"lazy\" attribute to defer loading of images", node: node)
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
theme-check-1.14.0 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.13.0 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.12.1 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.12.0 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.11.0 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.10.3 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.10.2 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.10.1 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.10.0 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.9.2 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.9.1 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.9.0 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.8.0 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.7.2 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.7.1 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.7.0 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.6.2 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.6.1 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.6.0 lib/theme_check/checks/img_lazy_loading.rb
theme-check-1.5.2 lib/theme_check/checks/img_lazy_loading.rb