Episode 20 game · Vayu · Air

Shrink the Bloat Asura

Kai’s login page has two boxes and one button, and it downloads 1052 KB of JavaScript first. Feel the weight of one bag for every page, cut it with tree shaking and import(), then prove each page downloads only what it needs.

VayuAir carries only what is light, Kai. Open your login page and let’s see how heavy it is.
20Seal 20
kai.app/login

Not opened yet

JS downloaded0 KB

On a slow phone: –

What’s in main.js example sizes, minified

    Open the page to weigh it.

    1 · Feel the weight

    Kai imports every page and all of lodash at the top of App.jsx. Open the login page, then weigh what it downloaded.

    Weigh it first

    A bundle visualizer draws every module by size. Start with the biggest box, never a guess.

    Shake the leaves

    Tree shaking drops unused exports only for ES modules in a production build. Use lodash-es, not CommonJS lodash.

    Split the routes

    lazy(() => import('./Reports')) turns a page into its own chunk that downloads when it opens.