mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Stop preloading zoom-modal images at render time (#4528)
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user