16

Add config.action_view.image_loading

 4 years ago
source link: https://github.com/rails/rails/pull/38452
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Member

jonathanhefner commented on Feb 14

edited

Browser native support for lazy loading images is now a part of the official HTML standard. To indicate to the browser that an image should be lazily loaded, add the loading="lazy" attribute to the img tag. Or, in Rails parlance, add the loading: "lazy" option to the image_tag call.

This commit adds Rails.application.config.action_view.image_loading to configure the default value of the image_tag :loading option. Thus by setting config.action_view.image_loading = "lazy", an application can opt in to lazy loading images sitewide, without changing view code.


Currently only Chrome and Edge support loading="lazy" (reference), but Firefox 75 will support it, and Safari will soon.

TODO

  • documentation
  • additional tests for the Railtie code

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK