Next.js Discord

Discord Forum

blurDataURL contains full webp animation in bundle

Answered
MattIPv4 posted this in #help-forum
Open in Discord
👋 I am trying to load a webp animation with next/image, and have optimization turned off (it was making the image larger than the source file somehow).

I originally tried with just unoptimized (no placeholder=blur or blurDataURL) and observed that the image being loaded made sense, but the JS bundle for the page appeared to contain a blurDataURL for the image that while never rendered on the page, put the entire webp animation in base64 into the JS bundle, massively inflating it.

I then tried setting unoptimized along with a custom blurDataURL that is just a 1x1 transparent gif, and even with that, the blurDataURL in the JS bundle is still the entire webp animation.

Code: https://github.com/alveusgg/alveusgg/blob/0e2e4c0a8ce42569972211ff3de7b1ddbb160295/apps/website/src/pages/updates.tsx#L61-L70
Live page: https://alveusgg-website-dwu0f0fom-alveus.vercel.app/updates

I have then since tried just using a plain img tag rather than next/image, and even with that, the blurDataURL value that contains the entire image in base64 is still in the JS bundle?! This makes Next.js completely unusable with animated images?!

Code: https://github.com/alveusgg/alveusgg/blob/35994c785204ff2232a486f2b7bd36f646957272/apps/website/src/pages/updates.tsx#L60-L71
Live page: https://alveusgg-website-e08naj1lp-alveus.vercel.app/updates
Answered by MattIPv4
Turns out this looks to be a tree-shaking bug, I filed https://github.com/vercel/next.js/issues/54012
View full answer

1 Reply

Turns out this looks to be a tree-shaking bug, I filed https://github.com/vercel/next.js/issues/54012
Answer