FREEFirst project with us? Your landing page design is on the house.See the offer

Glossary · Speed

What is Tree shaking?

By Abdul QuadirUpdated Nov 2026
Tree shakingnoun · Speed

Tree shaking is a build step that removes code a site imports but never uses. The result is a smaller JavaScript file for visitors to download.

Tree shaking is a build step that removes code a site imports but never uses. The result is a smaller JavaScript file for visitors to download.

Tree shaking, explained

Think of shaking a tree so the dead leaves fall out. If you use one function from a large library, a tree-shaking tool tries to ship only that function.

It relies on JavaScript modules, because import and export statements let the tool see what is used before the code runs. Bundlers such as Rollup, webpack and esbuild do this.

It is not magic. Code with side effects, or libraries in older formats, may be kept because the tool cannot be sure removing it is safe.

Less JavaScript means less to download, parse and run, which helps on slower phones. Shipping less in the first place, by avoiding big libraries, helps even more.

In our work

How Kookies uses it

We build with small vanilla scripts and few libraries, and Astro's build removes unused module code on the sites we make with it.

FAQs

Tree shaking
questions.

Abdul Quadir
Still have a question?Ask us directly. We reply within a day.
Book a callPick a timehello@kookies.io

Modern build tools usually do it by default in production builds, though how you import libraries still matters.

Not in the same way. Removing unused CSS is a similar idea but uses other tools.

Webflow manages its own output, so you do not control this. You can still keep your custom code small.

Your turn

Let's kook
what you krave.

Hi Kookies, I need a built on . I'd love to launch . Reach me at
or book a callSent. We reply within one working day.