Skip to content

Conversation

bengreenstein
Copy link
Contributor

@bengreenstein bengreenstein commented Jun 8, 2018

@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 )

@domenic domenic added addition/proposal New features or enhancements topic: img labels Jun 12, 2018
@domenic
Copy link
Member

domenic commented Jun 12, 2018

I did another minor pass; PTAL.

Copy link
Member

@domenic domenic left a 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

Copy link
Member

@domenic domenic left a 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.

@domenic domenic dismissed their stale review June 28, 2018 21:17

Things were fixed

Copy link
Member

@annevk annevk left a 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?

@jakearchibald jakearchibald self-requested a review July 25, 2018 14:42
Copy link
Collaborator

@jakearchibald jakearchibald left a 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).
Copy link
Collaborator

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).

Copy link
Member

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...

Copy link
Member

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.


<p>A <dfn>lazy loading attribute</dfn> is an <span>enumerated attribute</span>. The following
table lists the keywords and states for the attribute &mdash; 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>
Copy link
Collaborator

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?

Copy link
Member

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."

Copy link
Member

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)?

Copy link
Member

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...

Copy link
Member

@sideshowbarker sideshowbarker left a 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

Copy link
Member

@sideshowbarker sideshowbarker left a 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.

Copy link
Member

@sideshowbarker sideshowbarker left a 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?

@annevk
Copy link
Member

annevk commented Dec 11, 2018

@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 dev/styles.css for instance, which doesn't seem correct.

@sideshowbarker
Copy link
Member

This branch is now in a state that it can’t be rebased against master without multiple merge conflicts.

@bengreenstein
Copy link
Contributor Author

@sideshowbarker and @annevk Sorry about the state of the branch. Hopefully now it is all cleaned up.

Copy link
Member

@domenic domenic left a 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.

Copy link
Member

@domenic domenic left a 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.

@domenic
Copy link
Member

domenic commented Dec 21, 2018

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?

@domenic domenic added the needs tests Moving the issue forward requires someone to write tests label Dec 21, 2018
@domenic domenic dismissed jakearchibald’s stale review December 21, 2018 16:23

Comments addressed, I think!

@BitPopCoin
Copy link

I'd like a call back I can insert into an anchor or something to let me know when a location has been reached.

Copy link

@vertzjdean vertzjdean left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements impacts documentation Used by documentation communities, such as MDN, to track changes that impact documentation needs tests Moving the issue forward requires someone to write tests topic: img
Development

Successfully merging this pull request may close these issues.