Static Sites & Deployment

Asset Bundling

Definition

Bundling is what a build tool does to turn a developer's file layout into a shape browsers like. You write code as many small modules, each importing what it needs; a bundler such as Vite, esbuild, Rollup, webpack or Parcel starts at an entry file, follows every import, and writes the whole graph out as a handful of files. Along the way it usually does three related jobs: dropping code nothing imports, which is called tree shaking; splitting rarely-used routes into chunks loaded on demand; and running minification on what is left. The output filenames normally carry a content hash, such as index.7b2e4f.js, so each build produces new names for anything that changed. None of this alters what the code does — it changes how many files exist and how large they are.

Why It Matters

Every file a page needs is a separate request with its own round trip, and on a phone with 120 ms of latency three hundred small modules is a visibly slow page even when the total bytes are modest. Bundling collapses that to a handful of requests, and tree shaking often removes a third of the code that was never reached. HTTP/2 softened the penalty for many files by multiplexing them over one connection, so the argument today is less about request count and more about size and compression — a single larger file compresses better than many small ones. The opposite failure is real too: one enormous bundle makes every visitor download the admin screens they will never open. The useful target is a few chunks, split along routes.

How It Works

The bundler is pointed at an entry file and builds a dependency graph from its import statements, pulling in local modules and packages from node_modules alike. It then resolves that graph into output chunks, rewriting import paths, inlining small assets as data URIs and copying larger ones into the output folder. Text is minified, source maps are written alongside for debugging, and each chunk is named with a hash of its contents. The build step ends by rewriting index.html so its script and link elements point at the new hashed filenames. What you upload is that output folder; the source modules never leave your machine.

Real-World Example

An agency builds a client microsite from 180 small JavaScript modules and eleven stylesheets. Bundled, that becomes two scripts totalling 142 KB and one stylesheet of 18 KB, and the folder they publish to 99helpers at northbank-launch.99helpers.site contains fourteen files instead of two hundred. Page load on a mid-range phone drops from about 3.1 seconds to just over one. Nothing on the page changed visually; there was simply far less waiting for it.

Common Mistakes

  • Publishing the source folder because it looks like the real project — the browser cannot resolve bare package imports, so the site loads a blank page and a console error
  • Bundling everything into one file for simplicity — first-time visitors then wait for code belonging to pages they never open
  • Uploading a development build — it keeps debug helpers and skips minification, and is routinely three to five times the size of the production output

Related Terms

Put a file online in seconds

Drop in a document, an image, a page or a whole static website and share the link — free, with no build step and no server to set up.

Host a file free →