question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lazy loading of gallery thumbnails

See original GitHub issue

Loading 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:open
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
timhoffmcommented, Oct 24, 2022

My original idea was that this setting was applied to the gallery thumbnails only.

This would require an image option

.. image::
   :loading: lazy

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.

1reaction
tacaswellcommented, Oct 21, 2022

It seems the upstream feature request was implemented!

Implemented in Docutils 0.18. Thanks again for the suggestion.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found