Sha256: b9618b9650edba6a11238270032592c64bb477ca856fb8ef208f4ec913afbc8e

Contents?: true

Size: 499 Bytes

Versions: 19

Compression:

Stored size: 499 Bytes

Contents

# frozen_string_literal: true

module PlatformosCheck
  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)

      add_offense("Use loading=\"eager\" for images visible in the viewport on load and loading=\"lazy\" for others", node:)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
platformos-check-0.4.8 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.4.7 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.4.6 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.4.5 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.4.4 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.4.3 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.4.2 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.4.1 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.4.0 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.3.3 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.3.1 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.3.0 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.2.2 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.2.1 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.2.0 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.1.0 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.0.3 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.0.2 lib/platformos_check/checks/img_lazy_loading.rb
platformos-check-0.0.1 lib/platformos_check/checks/img_lazy_loading.rb