-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazyload images #3752
Lazyload images #3752
Conversation
I did another minor pass; PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some issues with the metadata fetcher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metadata fetching looks good to me editorially now. Eager to hear others thoughts on whether it provides the right foundation for interoperability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to update the element indexes to include this attribute for img and iframe.
Should this influence https://fetch.spec.whatwg.org/#concept-request-priority somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: img.decode()
waits for the image fetch to complete. With lazyload, this may take a long time, or might never happen. Is that the intent? Feels like decode()
is a strong signal that the developer wants the image to fetch.
source
Outdated
<tr> | ||
<td><dfn><code data-x="attr-lazyload-auto">auto</code></dfn> | ||
<td><dfn data-x="attr-lazyload-auto-state">Auto</dfn> | ||
<td>Indicates that the user agent may determine the fetching strategy (the default). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are cases where we need to define 'auto'. Expectations are pretty strong when it comes to new Image()
. Perhaps "off" is the default unless the image was created by the regular document parser (not innerHTML
and createContextualFragment
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of leaving auto free to experiment for now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new Audio()
sets preload=auto
, maybe new Image()
could set load=eager
to match expectations.
source
Outdated
|
||
<p>A <dfn>lazy loading attribute</dfn> is an <span>enumerated attribute</span>. The following | ||
table lists the keywords and states for the attribute — the keywords in the left column map | ||
to the states in the cell in the second column on the same row as the keyword.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this value is changed after element creation? Eg, if I switch from "on" to "off". Feels like the image should immediately load. Worth spelling out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is explicit in the spec's
user agents must obtain images immediately when the CSS boxes those images intersect the viewport, or when the corresponding img element's lazyload attribute is in the Off state
But maybe we can add a clarifying note right after that paragraph, saying "This means that if the author changes the lazyload attribute's value to Off, and the image has not already been obtained, it will immediately be obtained."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a possibly common use case. Is it clear that changing the state is the way to load the image, or should there be a load()
method (like for media elements)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that load()
would conflict with load
IDL attribute...
This CL implements support for the "lazyload" attribute on frames, according to whatwg/html#3752, and as part of the LazyLoad feature. The accepted values are: "on", which causes the browser to lazily load a frame even if it's same-origin or nested inside another lazyloaded frame, "off", which causes the browser to avoid lazily loading this frame or any of it's children (unless those children are marked with lazyload="on"), "auto", which activates the default behavior, and is therefore not explicitly handled in code. Bug: 873358 Change-Id: I2fde65adb15216260291b08e39888a2363f44d4a Reviewed-on: https://chromium-review.googlesource.com/1176293 Commit-Queue: Scott Little <sclittle@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Cr-Commit-Position: refs/heads/master@{#583841}
This CL implements support for the "lazyload" attribute on images, according to whatwg/html#3752, and as part of the LazyLoad feature. The accepted values are: "off", which causes the browser to avoid lazily loading the <img> element "on" and "auto", activate the default behavior of lazily load the <img> element When the attribute is changed to "off", the deferred image loads immediately. Bug: 875080 Change-Id: I839926a9827d019f23aafc40f8315476fe1b3048 Reviewed-on: https://chromium-review.googlesource.com/1197782 Reviewed-by: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org> Commit-Queue: rajendrant <rajendrant@chromium.org> Cr-Commit-Position: refs/heads/master@{#592599}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d suggest that since the change to the CONTRIBUTING.md and README.md files arenn’t directly related to the substance of the rest of this patch (lazyload feature), it’d be preferable for the CONTRIBUTING.md and README.md changes to be in separate patches from this patch. It’d be fine if they are just a separate commits as part of PR #3752 but not sure if that would happen, given that the policy here for PRs is that they result in a single (squashed) commit that gets merged to master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to dev/style.css for adding the syntax-highlighter styles have already been merged into master, so they should be dropped from this patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I’m now realizing that this reason some unrelated changes are showing up in the diff here are that this patch includes some merges? So it seems like it needs to be rebased against master to clear those away?
d2af159
to
da6a6f8
Compare
@bengreenstein could you rebase this against master and then force push the resulting changeset to get rid of the merge commits? As it stands it looks like this is proposing a number of changes against |
This branch is now in a state that it can’t be rebased against master without multiple merge conflicts. |
b2cdf21
to
c093e8c
Compare
@sideshowbarker and @annevk Sorry about the state of the branch. Hopefully now it is all cleaned up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some stuff to work out around images; I'm most concerned about srcset/picture.
Will look through other reviewers' comments and flag them also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small things and one big thing: what to do for srcset and picture.
OK, sweet! I pushed up a few minor tweaks of my own, almost all editorial. This now looks good to me. @jakearchibald, I think we addressed your comments, so I will dismiss your review, but if you have the time, a re-review would be much appreciated. From what I recall, this had pretty active and helpful support from WebKit at least in #2806. @smfr and/or @othermaciej, would you like to take a look at the results, probably using the diff links in the OP to see the rendered additions? From what I can see we haven't yet addressed the WebKit request to have a feature for a placeholder image while it is loading ("lowsrc"), but I think we went through a lot of the other questions in that thread and resolved them; please correct me if I'm wrong. @bengreenstein, are there web platform tests for this yet? |
I'd like a call back I can insert into an anchor or something to let me know when a location has been reached. |
In previous CLs, support for the lazyLoad attribute was added, but the corresponding idl attribute entries were mistakely forgotten. This CL adds those attribute entries, making it possible to detect if the browser supports native lazy loading from JavaScript. Spec: whatwg/html#3752 ChromeStatus entry: https://www.chromestatus.com/feature/5645767347798016 Intent to implement: https://groups.google.com/a/chromium.org/d/msg/blink-dev/czmmZUd4Vww/1-H6j-zdAwAJ Bug: 913162 Change-Id: Ib801c376ac70bf14eb2779e1642409f9cf03a95d Reviewed-on: https://chromium-review.googlesource.com/c/1372534 Commit-Queue: Scott Little <sclittle@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/master@{#622203}
whatwg/html#3752 landed, so remove comments and tentative extension.
whatwg/html#3752 landed, so remove comments and tentative extension.
whatwg/html#3752 landed, so remove comments and tentative extension.
whatwg/html#3752 landed, so remove comments and tentative extension.
…=testonly Automatic update from web-platform-tests Remove tentative from lazy load tests (#21773) whatwg/html#3752 landed, so remove comments and tentative extension. -- wpt-commits: 283eaa796815403a3e959861f6f1e61b0d35848f wpt-pr: 21773 --HG-- rename : testing/web-platform/tests/loading/lazyload/common.js => testing/web-platform/tests/html/semantics/embedded-content/the-img-element/common.js rename : testing/web-platform/tests/loading/lazyload/disconnected-image-loading-lazy.tentative.html => testing/web-platform/tests/html/semantics/embedded-content/the-img-element/disconnected-image-loading-lazy.html rename : testing/web-platform/tests/loading/lazyload/resources/image-loading-lazy-below-viewport-iframe.html => testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/image-loading-lazy-below-viewport-iframe.html rename : testing/web-platform/tests/loading/lazyload/resources/image-loading-lazy-in-viewport-iframe.html => testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/image-loading-lazy-in-viewport-iframe.html rename : testing/web-platform/tests/loading/lazyload/resources/image.png => testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/image.png rename : testing/web-platform/tests/loading/lazyload/resources/newwindow.html => testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/newwindow.html rename : testing/web-platform/tests/loading/lazyload/resources/referrer-checker-img.py => testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/referrer-checker-img.py rename : testing/web-platform/tests/loading/lazyload/resources/subframe.html => testing/web-platform/tests/html/semantics/embedded-content/the-img-element/resources/subframe.html
…=testonly Automatic update from web-platform-tests Remove tentative from lazy load tests (#21773) whatwg/html#3752 landed, so remove comments and tentative extension. -- wpt-commits: 283eaa796815403a3e959861f6f1e61b0d35848f wpt-pr: 21773
…=testonly Automatic update from web-platform-tests Remove tentative from lazy load tests (#21773) whatwg/html#3752 landed, so remove comments and tentative extension. -- wpt-commits: 283eaa796815403a3e959861f6f1e61b0d35848f wpt-pr: 21773 UltraBlame original commit: e201cb3f54180dcb5ea5203f472035bca7a1da14
…=testonly Automatic update from web-platform-tests Remove tentative from lazy load tests (#21773) whatwg/html#3752 landed, so remove comments and tentative extension. -- wpt-commits: 283eaa796815403a3e959861f6f1e61b0d35848f wpt-pr: 21773 UltraBlame original commit: e201cb3f54180dcb5ea5203f472035bca7a1da14
…=testonly Automatic update from web-platform-tests Remove tentative from lazy load tests (#21773) whatwg/html#3752 landed, so remove comments and tentative extension. -- wpt-commits: 283eaa796815403a3e959861f6f1e61b0d35848f wpt-pr: 21773 UltraBlame original commit: e201cb3f54180dcb5ea5203f472035bca7a1da14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont know what is going on but im not going to pay for this
@domenic
This is a draft of spec changes to support a lazyload attribute in iframe and img elements.
Issue: #2806
Tests: https://chromium-review.googlesource.com/c/chromium/src/+/1417117 (wpt export)
/embedded-content.html ( diff )
/images.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/media.html ( diff )
/rendering.html ( diff )
/urls-and-fetching.html ( diff )