Lazy loading of gallery thumbnails
See original GitHub issueLoading all tumbnails can take a significant amount of time/bandwidth (c.f. Matplotlib galleries).
It would be great if the loading could be deferred to the point when the user actually scrolls to the thumbnail.
Unfortunately, from a quick look this seems to not be easy. Lazy loading requires to change the <img>
tag to either have an attribute loading='lazy'
or use data-src
instead of src
(https://www.sitepoint.com/five-techniques-lazy-load-images-website-performance/) The thumbnail is generated via a .. figure::
directive (see THUMBNAIL_TEMPLATE
), which does not expose any of those.
Ideas are welcome how this could be solved.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Lazy Loading Images – The Complete Guide - ImageKit.io
Lazy Loading Images is a set of techniques in web and application development that defer the loading of images on a page to...
Read more >Lazy loading images - web.dev
This post explains lazy loading and the options available to you when lazy loading images.
Read more >Gallery Thumbnail doesn't shown with lazy loading enabled
I have a photos gallery, but the thumbnails for the images inside the gallery doesn't load properly, the image load perfectly after disable...
Read more >Optimizing Galleria | Galleria 1.6 documentation
6. Lazy load thumbnails · 1. Use reasonably sized images · 2. Use separate thumbnails · 3. Don't add too many images at...
Read more >Five Ways to Lazy Load Images for Better Website Performance
Lazy loading images means loading images on websites asynchronously — that is, after the above-the-fold content is fully loaded, or even ...
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 FreeTop 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
Top GitHub Comments
My original idea was that this setting was applied to the gallery thumbnails only.
This would require an image option
AFAICS, docutils has not implemented that. docutils 0.18 only added a global config parameter https://docutils.sourceforge.io/docs/user/config.html#image-loading but not a per-image setting.
Does this handle this issue?
I think that depends. The core issue here is that we want incremental loading of gallery images. Is it ok to tell users to globally switch to lazy loading for all content? If yes, then we can close. If no, we’d need to go back to docutils and request the per-image option, and when that’s done add a sphinx-gallery option to set that option for all thumbnails.
It seems the upstream feature request was implemented!