-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ideal image flashing when navigating back and forward #10214
Comments
I'm not sure we want to do anything by default. You should probably not optimize images that are in the initial viewport—these kinds of optimizations are for images that are not initially visible. Ideal image also does much more than lazy loading—there's low-quality placeholder, etc. |
This is not necessarily about images inside the initial viewport, you can scroll down and see a image and navigate to another page and then go back, and the images flashes
Low quality placeholder can be done with just a background image, load the image with different sizes based on the screen size can be done using |
I'm with you there. I would personally suggest not using ideal image, but not sure if we would go as far as deprecating the plugin. |
This plugin is quite old and difficult to maintain and reason about, with external dependencies being unmaintained forks. You can still use it in its current state, but we'll probably have to create a new image plugin from scratch sooner or later, it will be easier than upgrading the current one to modern std. |
Thanks, I'm thinking about if we can give it an option to use the browser native lazy load and srcset, we still want the plugin to do the image generation for multiple sizes though, this way we don't rely on that unmaintained library and the upgrade shouldn't be too hard? |
If you want to submit a PR you can. I'm not sure to understand what you have in mind and don't really plan to work on this in the immediate future. |
I mean we keep the other parts, just add an option to replace docusaurus/packages/docusaurus-plugin-ideal-image/src/theme/IdealImage/index.tsx Lines 94 to 107 in 868d72f
<img
height={img.src.height ?? 100}
width={img.src.width ?? 100}
src={img.src.src}
srcSet={...}
style={{
backgroundImage: `url(${img.preSrc})`,
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
width: '100%',
height: 'auto',
}}
loading="lazy"
{...propsRest}
/> If you're open to the idea I can take a look and try to make a PR |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
Image flashing when navigating back and forward using Ideal Image
A possible fix would be to use browser native image lazy loading
<img loading="lazy">
instead ofreact-ideal-image
(also posted in https://docusaurus.io/feature-requests/p/use-browser-lazy-loading-in-plugin-ideal-image)Swizzling code I'm currently using to avoid this problem
Reproducible demo
No response
Steps to reproduce
Expected behavior
No flashing
Actual behavior
Flashing
ideal-image-flashing.mp4
Your environment
Self-service
The text was updated successfully, but these errors were encountered: