Stop preloading zoom-modal images at render time (#4528)

This commit is contained in:
Nolann B.
2026-08-20 15:02:00 +02:00
committed by GitHub
parent 0dd2f4fbcd
commit 810244e8a9
2 changed files with 7 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"gitbook": patch
---
Stop preloading the zoom-modal variant of every zoomable image at render time; it downloaded each image twice during the initial page load. The modal image still loads on hover or click.
@@ -74,12 +74,8 @@ export function ZoomImage(
};
}, [imgRef, width]);
// Preload the image that will be displayed in the modal
if (zoomable) {
ReactDOM.preload(src, {
as: 'image',
});
}
// The modal image is loaded on demand (hover or click) by `preloadImage`; preloading it at
// render time would download every zoomable image twice during the initial page load.
const preloadImage = React.useCallback(
(onLoad?: () => void) => {
const image = new Image();