282 points · by saranshk · 6y ago · 176 comments
Which means, if you accept user generated content or images from any CMS or other source you really should be obtaining the image dimensions and using them in the HTML.
To actually prevent jumping (including on lean image load), I believe it would be more effective to simply set width and height.
Assume that developers make essentially random mistakes or changes. Whenever anything happens that has a negative impact on metrics management cares about, there will be pressure to look what went wrong.
Any random change that has a benign impact on measured metrics, eg weird page loading that makes people accidentally click on more lucrative links, there will be no pressure to revert.
No one needs to consciously look for and implement dark patterns for this to work out.
It's very similar to how confirmation bias can make people question news they don't like until they find enough evidence to disregard them; but are just accepting news they do like.
You don't.
You're not required to use it on every image. It's a completely optional parameter that you add to individual images that might benefit from it.
You can use it on navigation icons that don't change size. Maybe in some of your boilerplate in the footer. Or in some sidebar content or a testimonial that you control. But if you have images of unknown size populating the middle of the page, don't use it on those.
The 1.2 kB icon in the footer is not really a problem, but the xxx kB article image some author uploaded with unknown sizes.
Those things will make my page jump around and will need to be lazy-loaded.
The idea to set fixed dimensions feels like it comes from a time where we did designs with tables and "optimized" sites for 1024 x 768 pixel screen size.
That was the time when you could tell that this image should be displayed 200 x 200 px in size and nothing else. And it fit. One way or another.
I doubt we’ll ever see them built into a browser, because all nice generalized things never get there.
Using js onresize event is a no-go, if JS is still needed the spec is worthless. Lazy loading images with JS worked before just fine, this has to be about not needing special JS for this feature.
No, parent is right: It's impossible to satisfy that recommendation, usually.
And relative units don't fix this either as that information still misses the ratio of my image. If it's 100 vw, how high is it? I don't know this information without fetching the image, doing calculations and dynamically updating the DOM with that information.
I am not going to do this. This is such a pervasive issue, and with an _endless_ difference in screen sizes and millions of pages of content... not going to happen.
This kind of problem is exactly what the browser is best at solving. A problem everyone has on most pages on the internet.
1. The penalty for not displaying image dimensions is nearly insignificant because almost _all_ images that you would put width/height on are from content managers, not designers.
2. Mobile content: On a phone the content moves down after the image is loaded. (everything is just a single column) Which is a preferable action than a big empty space. So, I prefer _not_ including dimensions on user content for phones.
3. Responsive design: All CSS I have been using for years now has "max-width:100%".
Therefore (since a lot of traffic is mobile) most (rough guess) of images loaded from sites I've worked on the image dimensions are recalculated as soon as the image is loaded anyway.
4. Srcset: Multiple possible images downloaded that are _chosen_ by the browser at run time. You already have to provide dimensions. But what if they aren't exact? Go back to #1.
5. Web design: I can't even recall the last time I put an image in a design using the <img> tag that affected layout. (maybe if you go back to the 90s this would have mattered)
Is there an actual problem in identifying what images correspond to your markup and adding an appropriate attribute? (asking, not a web dev)
AFAICT the problem is solved, this is the necessary protocol - not even a bad one, use it and it will work.
Rarely do we specify the width of many, many objects and they display just fine. (consider tables)
But I will agree with the sentiment -- I find it incredibly annoying on pages that do lazy loading and don't implement this enlarged intersection check to make it appear seamless.
To learn photography I'd prefer starting with a camera. Not withe theory of light or the properties of atoms that allow glass to be transparent or how lenses are ground.
Similarly, if possible, to learn electronics i'd like to start at a higher level and work down rather than bottom up.
Are there names for these two types of teaching/learning approaches? Is one "better" than the other?
So basically is regular loading.
That way you get the behaviour of always-load and the rest of us get fast loading pages. This is a Pareto move.
Think about all the use-cases you could build. Maybe you could later set "I'm on a metered connection" at the OS level, have your browser pick that up, and not overuse your metered connection, etc. etc. Maybe you could have that in a browser extension that you manually toggle. No, this is far too useful.
And with some extra noise, maybe the Chromium based browsers follow.
If images aren't ready by the time you scroll down, this is more an issue with the particular implementation of lazy loading, but the concept is sound.
Of course, they aren't perfect at this, because in general figuring out what's above or near the fold is equivalent to the halting problem (thanks, Javascript!). They do it well enough for the typical case, though.
Lazy loading is all about the hosting costs.
However, if 40-50% of your visitors bounce because your page takes 5s to load[0][1] due to your longform photo essay hammering the user's 4G connection with a bunch of images they won't even see 5 minutes into scrolling down, this is a real concern. Lazy loading shines in these moments.
0. https://royal.pingdom.com/page-load-time-really-affect-bounc...
1. https://developers.google.com/web/fundamentals/performance/r...
If you refresh the page at the bottom, it will stay at the bottom, so no need to load top images.
Obviously this is an implementation detail and well done LL could keep loading everything until its done, but frequently it doesn't try until I scroll down. NonLL pages also aren't perfect, and if a page tries to load everything at once, each thing added slows everything else down. But for some reason I never experience that on non-LL pages (or maybe they're good LL pages and I don't notice.) It could be that browsers do some smart things (the obvious would be something like queueing requests for page content, only allowing 5 or so open requests, and loading images in the order they are referenced in the HTML so stuff at the bottom of the page is loaded last.)
In practice, it has the opposite effect when the browser needs to figure out where on the page the image will end up at before attempting to load it.
(This is not to say not to expect the polyfills, though)
Browsers could profile how long rendering a particular type of element takes on a given website, and optimize render triggers to provide seamless experience while conserving bandwidth.
Currently lazily rendering custom elements requires a fair chunk of IntersectionObserver boilerplate code, and beyond that any adaptability to user connection seems too complex to even consider.
If you replace your use of element with "blob of javascript" how would the browser separate out the "element" blobs that are "slow" from the other Javascript?
This is with a degree of imprecision overall, of course, but similar approaches I imagine could be used to profile individual element rendering times.
Edit: Tried to clarify my idea, being away from any browser developer tools at the moment myself.
The bug is already closed in Firefox. Hopefully it'll be here soon.
There is progressive loading embedded directly into JPEG and if browsers would prioritize loading of assets through the DOM (order), we wouldn't need any other solutions.
Or am I wrong here?
I’m honestly hoping that everyone quickly adopts the lazyload attribute, just so I can turn it off in one place.
all the more reason to make lazy loading a part of the language standards. if every site did lazy loading the same way, you could more easily disable it.
Here's a great article on sizes and srcset.
https://ericportis.com/posts/2014/srcset-sizes/
Editorial: Personally, my fear (based on history) is this will ultimately lead to more bloat, not less. The belief in "oh not to worry, we've got lazy load" is not a positive overall.
LL is a good thing. But it will likely increase abuse, not mitigate it.
Imagine if Microsoft, Apple, and Google were all sharing the same browser engine.
This argument may not make sense applied to an operating system/kernel. There are obvious benefits to having multiple competing operating systems. The crucial difference between a kernel and a web browser is that the kernel is a product, whereas the web (ECMA, W3C) is an international standard. So the only functional differences allowed to exist between implementations are at a very high level e.g. UX or privacy. The benefits of competing implementations are from innovation, but innovation in a way that violates the standard is not allowed, so innovation in functionality happens in the standards space. Where does innovation matter? In performance. Who can implement the standard with the best performance? It makes sense to have competition only up to such a point where a winner becomes 10x better than its competition. After that point it becomes useless to bet on the losers (save for extreme niches like lynx). There wouldn't be enough reward to heroically save the tied-for-last-place losers in a winner-take-all game.
It has to happen eventually. I think it would be quite sad to have flying cars on Mars and still have people working on rendering HTML.
This is the time we live in now, web standards are set by the ad industry
>Rob Buis 2020-02-13 00:04:07 PST
I was waiting for the spec to land before working again on this. First step is to fix the tests: https://github.com/web-platform-tests/wpt/pull/21773
I'll incorporate them into https://bugs.webkit.org/show_bug.cgi?id=200764, test a bit and hopefully put it up for review soon.
This is exciting. We should have all major browser supporting it within this year. Fewer Javascript required.
You can learn what the user have read on the page before, and deliver more relevant ads next.
> If scripting is disabled for img, return false.
> This is an anti-tracking measure, because if a user agent supported lazy loading when scripting is disabled, it would still be possible for a site to track a user's approximate scroll position throughout a session, by strategically placing images in a page's markup such that a server can track how many images are requested and when.
No, the change to the spec explicitly says lazy-loading is disabled if scripting is disabled just for this reason.
This has nothing to do with lazy-loading image tags. This browser-native functionality doesn't add any kind of new tracking, and pixels are never lazy-loaded anyway because they need to be fired as soon as possible to ensure data capture. Nothing about this new API changes anything for ads.
Lazy loading is entirely different and offers nothing new or useful for ads.
1. https://developer.mozilla.org/en-US/docs/Web/API/Intersectio...
Also in the last 5 years, every browser has added more functionality to block ads and tracking. Lazy loading is not going to somehow make up for that.
I mean, I get what you mean: you place pixels strategically to see how far someone got on the page. But you can do that and more already (even full screen interaction) and no one uses that for ad targeting.