Skip to content

Conversation

@IDisposable
Copy link

To allow lazy-loading of any image, add an API method swapInDataSrc that will copy the value from img-tag attribute data-src into src. This allows using a tiny placeholder image in the src, while still allowing preloading of the next image for easy transitions. Note that this is convention-driven to expect markup like <img src="placeholder.jpg" data-src="realimage.png" />. Any later DOM manipulation will work just fine because we pull the data-src attribute (and delete it) once. We could add the ability to specify the swapping attributes and such, but meh.

To allow lazy-loading of any image, add an API method swapInDataSrc that will copy the value from img-tag attribute data-src into src. This allows using a tiny placeholder image in the src, while still allowing preloading of the next image for easy transitions.  Note that this is convention-driven to expect markup like <img src="placeholder.jpg" data-src="realimage.png" />.  Any later DOM manipulation will work _just fine_ because we pull the data-src attribute (and delete it) once.  We could add the ability to specify the swapping attributes and such, but meh.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant