quru / image-defer Goto Github PK
View Code? Open in Web Editor NEWA simple, dependency-free JavaScript library for lazily loading images on a web page
License: GNU Affero General Public License v3.0
A simple, dependency-free JavaScript library for lazily loading images on a web page
License: GNU Affero General Public License v3.0
Amazingly, all the major browsers seem to suffer from a bug where repeatedly changing the src
of an image, even just toggling it between 2 values, causes memory use to grow without bounds:
This bug renders image-defer's maxLoaded
feature useless, and in fact image-defer just makes it worse when maxLoaded
is in force, because it causes the src
attributes to change more often than it otherwise would.
The issue is reproducible with the image-defer live demo page in latest Firefox 53 and Chrome 58. Just set the limit to 10 then repeatedly scroll up and down.
Given that the browser vendors haven't fixed this in 5 years, some kind of workaround will be needed. It might be possible, instead of just changing the src
, to replace the image's DOM element with a clone of itself already set to the new src
. The browser should then garbage collect the old DOM element along with the image data it contained. The DOM element in image-defer's _state.images
will also need to be replaced.
It should be relatively simple to add support for the HTML5 srcset
attribute, using that in preference to src
when both are present, and if the browser supports it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.