Hacker News new | ask | show | jobs
by account42 1154 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.

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.