Chrome to get lazy load below-the-fold images and iframes
groups.google.com
groups.google.com
So it seems the only way to correctly implement that is to open a connection to load an image and stall it after receiving the content-type and appropriate image header and hope that the server will not close the hanging connection(?)
PS: Seems that chrome will download the first 2K if byte-ranges are supported. If there is no dimensions in the first 2kb or byte-ranges are not supported, the full image will be downloaded non-lazily https://docs.google.com/document/d/1691W7yFDI1FJv69N2MEtaSzp...
It tries things in this order:
1. If the full image is present and fresh in the cache, then use that.
2. Otherwise, if the server supports range requests, and the image dimensions can be decoded from the first 2KB of the image, then generate and show an image placeholder with the same dimensions.
3. Otherwise, fetch the entire full image from the server as usual.
So, it'll only lazy-load images if it's in the cache or certain criteria is met. Also, it seems like it's opt-in using an attribute, so the implementer of the website can avoid it if they're worried. But overall, there won't be any reflow issues.
https://docs.google.com/document/d/1691W7yFDI1FJv69N2MEtaSzp...
It doesn't say anything about when the dimensions are known and I would assume it's using those in that case.
However, loading 2KB of an image is enough for most image formats to determine the dimensions even if they aren't specified in the hosting document (because most image formats contain a header specifying dimensions).
- If the image is fits in 2kb (icons/ui elements) then they can just do a full decode and not have to lazy load these ui items as the page scrolls.
- It allows them to load low resolution versions of progressive image formats rather than stick up a generic placeholder (marked as a future improvement right now).
I am going with the explicit image dimensions, srcsets and no lazy loading, which happens to be a feature of mod_pagespeed. With figure elements or picture elements for the content images, populated with the srcsets, I see this new browser side lazyload as the missing feature needed to preserve document structure, not have any javascript cludges and serve images in a way that respects data saving and viewport size.
Time to add the new 'lazy' attribute. Firefox and Safari users might not benefit yet but this is no need to wait.
[0] - https://docs.google.com/document/d/1e8ZbVyUwgIkQMvJma3kKUDg8...
* "Speed up the load of above-the-fold content, since there will be less competition for network resources during the initial page load"
Why don't they just set a low priority for offscreen images and resources? Isn't this the entire premise for HTTP/2, that multiplexing with priorities and flow control would load the important data first? Do servers not implement the spec correctly? So this reason is BS as the data saved is immaterial.
* "Reduce memory usage."
Even commodity phones come with several gigabytes of RAM, the memory may have to be used anyway if the user scrolls, and if you have unlimited scroll or massive scroll something will need to unload data anyway. So this reason is marginal at best.
* "Save network data by avoiding downloading any deferred content that the user doesn't end up scrolling to"
Most phone plans are unlimited or have data capable of watching movies. On Google's own Fi plan "less than 1% of individual Fi users ... use above 15 GB". So this is another BS reason as the data saved is immaterial.
So why are they actually pushing this?
Under "privacy considerations": "so slightly more information about the user's scrolling position on the embedding page is exposed" and "a deferred cross-origin image gets an additional piece of information about the user's scrolling position".
This is not hard to figure out - they are barely even trying to hide it. Same thing as pushing HTTP/2, which I contend was at least partly to track people using socket IP:port address (for instance by keeping a single connection to google-analytics open that all domains' data goes through and boosting the connection keep alive from a few minutes to like half an hour, which they did).
And what delicious irony if they couldn't solve this with HTTP/2 because of servers not implementing the spec correctly or having weird undocumented quirks (their reason for not enabling pipelining despite it working just fine).
I learned to debug by looking at the system data usage monitors - the standard power usage per app wasn't helpful. Turned out the problem was just a data hungry photo app we were developing at the time. We made it nicer on data usage before we launched.
And after all that, chrome was usually in my top 3 apps for data usage. Probably still is. So they absolutely should be optimizing it.
Granted that was several years ago but in some parts of the world that phone would probably be better then what the average consumer uses today.
Can you explain what you mean? Chrome does not have any customers.
> And what delicious irony if they couldn't solve this with HTTP/2 because of servers not implementing the spec correctly or having weird undocumented quirks (their reason for not enabling pipelining despite it working just fine).
How do you envison the browser to solve this when the server is not H2 capable?
I use Google Fi and I use less than one gigabyte a month: not because I'd like to, but because I don't want to pay for mobile data when I don't have to.
The reality is that lazy loading images really does help webpage performance, especially on mobile. You cannot properly implement it in the browser without additional information from the page developer - because you'll never know which images are so important that they will always need to be loaded, and which ones can be lazy loaded once they're almost in view.
We're talking about the addition of one attribute to the <img> tag here. There's no conspiracy, and there's no ulterior motive.
Google should need some really good evidence to support this.
What points do you disagree with, and why? Where are the metrics? If it's better performing than just priorities and flow control then by how much, and how do you justify breaking sites to achieve that margin?
Wasn't part of the spec and Mozilla is doing it via a page permission. Just Google about the chrome autoplay audio and you'll see plenty of issues about how they rollout features.
Google has shown this is exactly what they plan to do with their Monopoly before with chrome-specific features that require the developer to be aware of.
You meant to say that are aren't trying to hide it, right?
No, most phones do not have unlimited data at all.
I am not even starting with your conspiracy theory.
I am pretty sure when Chromium engineers look at same data for these decisions, but hey, maybe you have some numbers to share.
On what do you base this claim? My experience is the opposite - most people I know have less than 3GB/month. Do you have any actual data?
It is also my experience that unlimited bundles (which aren't unlimited anyway, they're just limited to an amount that virtually nobody hits which is quite a difference from "we can make them use as much data as we want") are rare rather than the norm.
Thanks, I'll take Google's solution.
It’s good they’re implementing this, but it will mislead people to thinking the whole website is ready to use. It’s a shame an option couldn’t be “load the rest after page load”.
I never actually implemented it, though, just seemed like a nice idea. Anyone know if existing data fetching frameworks (e.g. Apollo Client) can do anything like that?
Also, do we yet unload images (from memory) after a user scrolls far past them?
I’m always surprised how slow “long” webpages become.
Last time I looked, the answer was no for images but yes for background images. I implemented a lazy-loader which did the latter for a pretty significant measured improvement on gallery pages.
[0]: https://news.ycombinator.com/item?id=19602877 > Under "privacy considerations": "so slightly more information about the user's scrolling position on the embedding page is exposed" and "a deferred cross-origin image gets an additional piece of information about the user's scrolling position".
https://bugzilla.mozilla.org/show_bug.cgi?id=1535749
But the last comment raises concerns about privacy implications it may have. So, I think that right now it is unclear whether Firefox will eventually implement it and in what form.
On Android Chrome with Data Saver turned on, elements with loading="auto" or
unset will also be lazily loaded if Chrome determines them to be good
candidates for lazy loading (according to heuristics).
I don't agree with this design decision to make the default ("or unset...") allow for lazy loading, even if limited to Data Saver enabled phones. Doesn't this mean every site on the planet that deems Android >= 7.0 web traffic important and makes use of pixel-based or iframe-enclosed tracking will have to go through testing and potential modification?I would be curious if this would also be apply to email clients that render using Chrome.
You must have heard "lazy" before, but eager is a term of art as well: https://en.wikipedia.org/wiki/Eager_evaluation