Hacker News new | ask | show | jobs
by capableweb 1153 days ago
Believe it or not, but websites could already implement it based on what the user-agent knows about the connection already. `navigator.connection` (returns NetworkInformation - https://developer.mozilla.org/en-US/docs/Web/API/NetworkInfo...) supposedly holds what the user-agent thinks the connection-type is. Although not implemented in Safari nor Firefox.

Although I do think there are concerns around privacy when it comes to adding more bits people can use to track you, which is probably why it's not implemented in Safari or Firefox yet.

Automatically doing lazy-loading of <img/> tags based on information not shared with the websites probably would break random websites that depend on being able to load images outside of the view of the user, for one reason or another, so probably won't be possible to fix by now.

1 comments

> Believe it or not, but websites could already implement it based on what the user-agent knows about the connection already. `navigator.connection` (returns NetworkInformation - https://developer.mozilla.org/en-US/docs/Web/API/NetworkInfo...) supposedly holds what the user-agent thinks the connection-type is. Although not implemented in Safari nor Firefox.

This is absolutely the wrong way around. I don't care much for lazy loading but if you must add it then use the loading="lazy" hint and let the browser decide based on that. Don't try to be smart, e.g. navigator.connection won't tell you that I'm about to get on a plane where I won't have internet at all.