Menu

My Bundle-Size Gate Passed for Months Because It Was Weighing the Wrong File
πŸ“°

My Bundle-Size Gate Passed for Months Because It Was Weighing the Wrong File

DEV Community: javascriptΒ·seller-mindΒ·2 days ago
#20Z9XS6J
#devtojavascript#devto#dev#widget#file
Reading 0:00
15s threshold

Parcelglance puts a chat widget on Shopify storefronts. Third-party scripts on a storefront are guilty until proven innocent, so I made myself a promise and encoded it as a build check: the widget ships under 50 KB gzipped, or the build fails.

For months, every deploy printed this:

> postbuild > node scripts/check-widget-size.mjs

[widget-size] public/parcelglance-widget.js raw: 12.24 KB gzipped: 3.77 KB (limit 50.00 KB) βœ… Under the 50 KB gzipped claim.

Enter fullscreen mode

Exit fullscreen mode

Green. Every time. And meanwhile the file most merchants were actually downloading was 78 KB raw, about 75 KB over the wire, and the widget wasn't loading for a large group of them at all.

Three separate things were wrong, and the size gate was the one that made the other two invisible.

Two files, one gate, no overlap

The app had grown two ways to put a widget on a storefront.

The first was a theme app extension: a Liquid snippet that loads a loader script, which loads the real widget from /widget.js .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.