Native image lazy-loading for the web
addyosmani.com
addyosmani.com
I guess an advantage of a 'native' feature could be that browsers could offer a button saying 'please pre-load this page!'
Sadly, Apple has been like this since since at least the late 1980's. Out in the desert trying to help 150 children sign up for health care coverage and need to look something up via satellite connection? Oh, wait... the macOS is downloading Garage Band crap in the background that I didn't ask for and don't need. (I don't remember if Garage Band was the offender, but it was one of the pointless programs wasting space on my business computer).
Just like app developers who only test their apps on the high-end phones they have, not the phones that the majority of people have.
For the web sites I make for work, I test them on all kinds of devices. But I make sure that they all work on the cheapest pre-paid smartphone I could find at 7-Eleven.
The internet was built to bring universal information to all, not just Flash games to the rich.
(And if you had GarageBand in the late 1980s, then I definitely want to know who sold you your time machines...)
And then they’re back after the next OS upgrade.
I know it was for a while, but since the iLife apps were added to the Mac App Store, I thought they no longer reinstalled automatically, and if you wanted them back you just downloaded them from the Store. However, I haven't deleted them myself, so I don't know offhand.
> Just like app developers who only test their apps on the high-end phones they have, not the phones that the majority of people have.
I'm a little surprised by your reaction to this feature, accusing it of being part of the tech bubble, given that you said that you make sure to develop for the phones that the majority of people have. Part of the motivation for native lazy-loading is to provide a better web experience for people in countries where network data costs a lot. Lazy-loading images is a step in the right direction, because it helps ensure that the only images that users download are the ones they look at.
It's not a perfect solution, as radarsat1's use case demonstrates. But it seems like a step in the right direction.
Disclosure: I work on the same team as Addy. I'm not speaking on behalf of the team, just commenting based on my understanding of the motivation for features like this.
Heheh don't feel too bad for me, I live in a major European city with service on most of the lines. Just not _all_ of them -- so I suspect that's the same for most people.
The OS could then automatically apply this to website load behavior, and apps could request permission to receive this information too. E.g. Spotify could pre buffer more of the playlist you’re listening to, and news reader apps could load a few articles in advance.
I think you are spot-on here. The current JavaScript hacks cause problems, handing the control to the browser is a much better solution.
but I'm also worried about the "unloading" of these resources. with a proper implementation you don't only load first images into view and preload the others, but also unload those out of view to ease the compositing load on older gpu - and older iphones that have most their ram eaten by the updated ios are really problematic, especially because when the gpu crashes with an out of memory error safari shows a "the website crashed" message that puts the blame on the page instead on its own shitty memory management.
You don't need a native feature for that. Just emulate a big screen and dispatch a scroll event, that's what SingleFile [1] does.
> Wait until the page is fully loaded, you may need to scroll down the entire page to be sure all elements are loaded.
You say it solves this, but then why does it say this?
I guess not on Medium, but it's very common for sites to unload any image that isn't in the viewport, so...the joke's on us.
Medium, and similar websites, should push their images via HTTP2.
But as everything in life, it depends, read my use case for lazy loading…
I maintain a few marketing websites for a game studio, and as you can guess these websites contain several high-resolution images that —according to the marketing team— need to be loaded all together from the front page. This is obviously a stupid requirement, but I don’t get paid to complain, instead I decided to add lazy loading to these websites. Many users just visit the home page to access the navigation bar, and jump to internal pages specific to the games they are interested in, they don’t care about the rest of the content, so why should I —as the maintainer of these websites— force the immediately download of all these heavy images?
I, too, pay for a limited mobile plan (CAD $95 for only 3GB per month, yeah, I know, it’s very expensive) so of course I want to avoid the download of unnecessary resources from every website I visit. Unfortunately, I do not maintain every major website in the Internet, so I cannot optimize things for the masses. I can only give a good example using the websites I maintain. I am looking forward to have `loading="auto"` enabled by default in every modern web browser, that or 5G with less expensive data plans, but that’s a different story.
I like the basic loading idea, I think it is a little problematic since the Browser Vendor gets to decide how it is loaded. I kind of understand why we need this with, but most of the implementation sucks. They keep thinking about optimising for Network, bandwidth or resources and not the User Experience.
In the Medium Example, I don't want to see image loading, it is annoying. Images should always be preloaded before I scroll down. Something like ~2 / 3 Fold below the current view should have been fully loaded. So Scrolling ( In general pace ) down all content should be there already.
Ideally, you could add an article to the Reading List on your computer, and then view it later on your phone that downloaded it in the background when it still had network access.
In practice, my quick testing results just now were mixed: Safari kept saying that a Medium article wasn’t available offline, a Quartz article only loaded the header (with what looked like a fully-opaque white overlay covering the content itself), but a Daring Fireball post (i.e., without any JavaScript trickery) loaded just fine.
A how-to for this feature: https://www.macworld.com/article/3252168/how-to-set-offline-...
I would prefer to choose for myself whether images load eagerly or lazily on all sites I visit. This way, I would always know which type of loading to expect as I browse, and I would always get the type of loading I prefer.
It seems a little premature to describe this as native support "for the web" if the functionality is limited to one vendor and you're forced to use a polyfill everywhere else.
You can find the full discussion here: https://github.com/whatwg/html/pull/3752
I just filed https://github.com/mozilla/standards-positions/issues/151 on getting an actual Mozilla position on this.
https://hacks.mozilla.org/2019/03/scroll-anchoring-in-firefo...
<Suspense fallback={<Placeholder />}> <Image src="" /> </Suspense>
When SSR, this one will show a real <img> tag. When SPA, this one will lazy load image.
A Win-Win for both devs and customers.
IE: <img src="celebration.jpg" loading="optional" alt="..." />
Then there is a place-holder graphic in place that you could click on to load the image.
Excited to see what else they are going to bring to the browser to speed up sites.
The browser knows what’s on the page and can optimize its loading already. Don’t screw with that. This kind of assistance from the browser is why.
Also, you don’t need to run code in documents. Web pages are documents.