Skip to content

Reduce unused JavaScript

Build-pipeline + runtime fixes without breaking the design

  • Senior engineers · IST + EST overlap
  • NDA on day 1
  • 24-hour reply

Tell us what you need fixed

Reply in 24 hours · NDA on day 1 · No spam.

Reduce unused JavaScript — done properly, by senior engineers

Removing dead weight is the job here: Krapton’s engineers reduce unused JavaScript that PageSpeed Insights flags as downloaded during page load but never executed. The Lighthouse audit compares the bytes each script ships with the bytes that run before load finishes, so it mixes two different problems. Some code is never needed: a whole utility library imported for one function, polyfills for browsers you no longer support, dead feature flags. Other code is needed later, such as a checkout modal, an editor or a chat widget, but is fetched up front. Delete the first kind; split the second and load it on use. Treating both the same is why blanket lazy loading sometimes makes interactions slower. The work starts with the Lighthouse treemap and the DevTools Coverage panel, maps unused bytes to modules through source maps and a bundle analyzer, and traces why each module lands in the initial chunk. Typical fixes include narrowing browserslist, switching core-js to usage-based polyfills, replacing barrel and CommonJS imports that defeat tree shaking, splitting by route and interaction with dynamic import(), and placing embeds behind facades. A size-limit budget in CI keeps the bundle from creeping back. You receive a module-level report, the PR and the budget config.

What you're seeing

PageSpeed says "Reduce unused JavaScript — 400 KiB" and your bundle analyser confirms it.

Our approach

We tree-shake polyfills, dead-code-eliminate unused utilities, code-split per route, and lazy-load third parties, measuring shipped JS per route before and after.

Symptoms teams come to us with

  • PageSpeed Insights shows “Reduce unused JavaScript” with your vendor chunk or main bundle listed first.
  • The DevTools Coverage panel marks most of a large chunk as unused after the page loads.
  • The bundle analyzer reveals all of lodash, every moment locale or an entire icon set in one chunk.
  • Every route downloads the same large shared chunk, including code for admin or checkout screens.
  • Bundle size grows with each release, and nobody notices until a PageSpeed report flags it.

What we check first

  1. Barrel files and namespace imports pull whole packages into the bundle when only a few exports are used.
  2. A broad browserslist and core-js entry imports ship polyfills that modern browsers never need.
  3. CommonJS dependencies or missing sideEffects flags stop the bundler from tree shaking unused exports.
  4. Code for modals, editors and below-the-fold widgets is imported statically instead of through dynamic import().
  5. Third-party embeds such as chat, video and maps load their full SDKs on every page.

Concrete deliverables, no fluff

Every engagement ends with measurable, documented outcomes — no black-box agency reports.

  • Diagnostic report with reproducible steps
  • Implementation merged behind a PR you review
  • Verified fix across browsers and devices
  • Knowledge transfer to your engineering team

What changes after we ship

  • Module-level map of wasted bytes

    A report ties each block of unused code to a package, import statement and route, ranked by transfer size, so decisions rest on evidence rather than guesses.

  • Polyfills matched to your audience

    Browser targets come from your own analytics, and polyfills are injected only where needed, so modern browsers stop downloading compatibility code they never run.

  • Routes ship only their own code

    Route-level and interaction-level splitting keep admin, checkout and editor code out of public page loads, while prefetching keeps later navigation quick.

  • A bundle budget enforced in CI

    size-limit or a bundler performance budget fails the pull request when a chunk grows past its agreed size, with the analyzer output attached for review.

From brief to shipped fix

A transparent, low-risk process — a senior engineer reads your brief personally, and nothing starts until you approve a written plan and price.

  1. 01Day 0–1

    Diagnose

    A senior engineer reviews your brief, reproduces the issue, and pinpoints the real root cause — not the symptom — before any code is touched.

  2. 02Within 24h

    Scoped plan & quote

    You get a written plan to reduce Unused JavaScript, a firm timeline, and a fixed quote. Nothing starts until you approve it — no surprise invoices.

  3. 031–2 weeks

    Ship the fix

    We implement on a branch and open a pull request you review, working to your code-review standards on your repo — never a black box.

  4. 04On delivery

    Verify & hand off

    We verify on staging and production, share before/after evidence where it applies, and leave you a short hand-off note so the fix sticks.

Situations we handle

  • Marketing pages inside an SPA

    A marketing site built inside the product’s single-page app downloads dashboard code on the homepage. Separate entry points or route-level splitting keep landing pages light without a second codebase.

  • Legacy app with old polyfills

    A codebase still configured for Internet Explorer ships Promise, fetch and Array polyfills to every visitor. Updating browserslist and the Babel or SWC targets removes them without breaking supported browsers.

  • Design system import bloat

    A component library exported through one index file pulls every component and icon into each page. Per-component entry points, correct sideEffects settings or Next.js optimizePackageImports restore tree shaking.

Why teams hand this task to Krapton

  • Senior engineers only

    Your brief is read and handled by a senior engineer — no junior hand-off, no sales-rep filter in between.

  • Root cause, not a patch

    We reproduce and fix the underlying cause, then add a guard so the same class of issue does not quietly return.

  • Your repo, your standards

    Every change lands as a pull request you review, on your repository, following your existing review process.

  • NDA on day one

    Confidentiality and IP are covered before we look at a single line of code. All work stays in your accounts.

  • Fixed quote up front

    You approve a written plan and price before work starts. If scope changes, we re-quote in writing — no surprise invoices.

  • Proof, where it applies

    Performance, SEO and reliability work ships with before/after evidence so the result is measurable, not anecdotal.

Three ways to engage

No retainer required. Pick the model that matches the work — pricing for this task starts from $500, with a fixed quote before anything starts.

  • Per task

    Most popular

    One clearly-scoped fix at a fixed price. Best when you know exactly what is broken and want it handled end to end.

    • Fixed quote up front
    • One PR, reviewed by you
    • No retainer required
  • Hourly

    Pay only for the hours worked. Best for diagnostics, audits, or exploratory work where the scope is still emerging.

    • Weekly timesheets
    • Pay for what you use
    • No minimum commitment
  • Per sprint

    A focused 1–2 week sprint when the work is bigger than one fix but smaller than a full project.

    • 1–2 week blocks
    • Clear sprint goal
    • Scale up or stop anytime

Industry-standard stack, no proprietary lock-in

  • TypeScript
  • Webpack
  • Vite
  • esbuild

Reduce unused JavaScript — your questions, answered

How much does it cost to reduce Unused JavaScript?

Pricing starts from $500 and depends on the scope we find during the diagnostic. You get a fixed, written quote before any work begins — most engagements like this run 1–2 weeks.

How long does it take to reduce Unused JavaScript?

Typically 1–2 weeks for a focused engagement. After a short diagnostic we commit to a firm timeline so you know exactly what to expect.

Should we try to reduce unused JavaScript to zero?

No, and chasing zero is not useful. Any interactive page ships some code that runs only after load, such as handlers for menus or forms, and Lighthouse counts it as unused. The goal is to remove code that is never needed and defer code that is needed later, without making the first interaction wait on a network request.

Is lazy loading everything a good way to cut unused code?

No. Lazy loading code that is needed right after load adds a network round trip at the moment of interaction, which can make the page feel slower. We lazy load code tied to rare or deliberate actions, such as opening an editor, and prefetch code for likely next steps, so the audit improves without hurting responsiveness.

How do you keep unused JavaScript from coming back?

With a budget the build enforces. We add size-limit or bundler performance budgets per entry point, run them in CI, and post the bundle analyzer diff on pull requests that change dependencies. A no-restricted-imports lint rule can block known heavy imports, such as a whole utility library, so reviewers see the cost before merging.

Let's get this off your plate

Send a 60-second brief on Reduce Unused JavaScript and a senior engineer replies within 24 hours with a plan and a fixed quote. NDA on day one, no retainer required.