Re:Show HN: The smallest and most narcissistic image lazyloa...
by l1am0 on Wednesday December 18, 2019 @12:50PM
(#21827344)
IMO lazy loading the images on your websites is a good idea in 99% of the cases. As all the other lazy load libraries where way to heavy for use case I build lazy-simon.js.
It is build with JavaScript intersection observers. To keep it below 500 byte it currently only works with img tags, but I may adapt it for more HTML tags if that is useful.
I do not plan to add a lot of config options, as there are nice highly configurable lazy loading libraries out there. Mine should just be a script include and you are done :D
Re:Show HN: The smallest and most narcissistic image lazyloa...
by alexza on Thursday December 19, 2019 @08:06AM
(#21834531)
Some browsers like chrome support this functionality natively by setting the image attribute loading="lazy" (https://web.dev/native-lazy-loading/) You could improve your library by adding a check wether the browser supports it natively, if yes use the loading attribute, if no use the visibility observer
It is build with JavaScript intersection observers. To keep it below 500 byte it currently only works with img tags, but I may adapt it for more HTML tags if that is useful.
I do not plan to add a lot of config options, as there are nice highly configurable lazy loading libraries out there. Mine should just be a script include and you are done :D
`data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"><style>svg{background: grey;}</style></svg>`
And don't bother with the color there, just set a background-color on all IMG elements in CSS, the svg will be transparent.