Add opt-in support for the native loading="lazy" attribute - #64
Open
bharat3645 wants to merge 3 commits into
Open
Add opt-in support for the native loading="lazy" attribute#64bharat3645 wants to merge 3 commits into
loading="lazy" attribute#64bharat3645 wants to merge 3 commits into
Conversation
Closes jekyll#51. Adds an opt-in `loading=lazy` tag argument that sets the browser-native `loading="lazy"` attribute on the rendered `<img>` and uses the regular `src`/`srcset` attributes (not `data-src`), as requested in the issue. The existing `lazy=true` (JS-plugin-based, `data-src`/`data-srcset`) behavior is untouched and takes precedence if both are somehow present.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #51
What
Adds an opt-in
loading=lazytag argument that renders the browser-nativeloading="lazy"attribute on the rendered<img>:{% avatar hubot loading=lazy %}Why
#51 asks for native lazy-loading support that keeps the regular
srcattribute. The existinglazy=trueoption emptiessrcand moves the URL intodata-src/data-srcset, which requires a JavaScript lazy-load plugin. This new option instead keepssrc/srcsetintact and addsloading="lazy", so images work with zero JS — exactly what the issue requests.Behavior notes
lazy=truebehavior is untouched and takes precedence if both arguments are somehow passed.native lazy loadingcontext) mirroring the existinglazy loadingspec; the new option is documented in the README.