From 810244e8a96c3b97f3601d824277f07db4e0ca24 Mon Sep 17 00:00:00 2001 From: "Nolann B." <100787331+nolannbiron@users.noreply.github.com> Date: Thu, 20 Aug 2026 15:02:00 +0200 Subject: [PATCH] Stop preloading zoom-modal images at render time (#4528) --- .changeset/light-parts-repeat.md | 5 +++++ packages/gitbook/src/components/utils/ZoomImage.tsx | 8 ++------ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 .changeset/light-parts-repeat.md diff --git a/.changeset/light-parts-repeat.md b/.changeset/light-parts-repeat.md new file mode 100644 index 000000000..98c5770da --- /dev/null +++ b/.changeset/light-parts-repeat.md @@ -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. diff --git a/packages/gitbook/src/components/utils/ZoomImage.tsx b/packages/gitbook/src/components/utils/ZoomImage.tsx index 4d294f81a..7e221a3ae 100644 --- a/packages/gitbook/src/components/utils/ZoomImage.tsx +++ b/packages/gitbook/src/components/utils/ZoomImage.tsx @@ -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();