How does this even work if your not overriding src?
See original GitHub issuePretty much all lazy loaders need to use src2
or override it in some way due to the browser automatically fetching images with a src
value - so I’m a bit baffled how does this library work exactly?
Does this library just hope that it can kick in quick enough to alter the attributes on dom load? (sounds rather fragile and unreliable if so…)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Class is not Abstract and does not Override error in Java
You created a class Cat which implements an interface Animal. Your interface called Animal has an abstract method called roar which must be...
Read more ><iframe>: The Inline Frame element - HTML - MDN Web Docs
Inline HTML to embed, overriding the src attribute. If a browser does not support the srcdoc attribute, it will fall back to the...
Read more >Content Configuration
Configuring source paths. Tailwind CSS works by scanning all of your HTML, JavaScript components, and any other template files for class names, ...
Read more >Working With Files
As described in the Apache Ant manual, the mkdir task will automatically create all necessary directories in the given path and will do...
Read more >How to use @font-face in CSS
If you open the URL for the font, you can actually see all the ... SVG fonts are not currently supported by Firefox,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@garygreen thanks again for bringing up your idea with ServiceWorkers - it sadly took a lot of time due to several reasons to come up with a PoC and an evaluation of this topic.
I’ve identified the following aspects:
Pro
img
oriframe
elements wouldn’t need to get wrapped by anoscript
HTML tag any more, but still (as you’ve even also stated) we would need to identify the assets that are supposed to get lazy loaded. As Client hints within the HTTP headers aren’t an option here, I’ve mainly identified that the best would probably be query parameters added to the URL (I even also thought about implementing those via the anchor, but this might have unexpected side effects regarding caching). Additionally we would need to retrieve thewidth
andheight
(same values like the equally named HTML attributes) of the image for the SVG placeholder, which could as well get transferred via query parameters.Con
Still these might be tradeoffs that someone might be accepting due to the simplification regarding the HTML code changes.
Conclusion
I’ve uploaded this very simple PoC to this URL - it doesn’t include any lazy functionality so far, but differentiating in between loading-lazy and non-loading-lazy could be done with removing the query parameters: https://goofy-bell-6b1148.netlify.app/
I’m still motivated to even also offer this other solution as a new polyfill though.
I‘m loving your idea and it‘s actually a nice approach worth looking into. Especially as there‘s no other way I could think of to intercept the network traffic - or in other words this might be an even nicer one which even also further follows the principals of progressive enhancement.