Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Build artifact missing assets (404 JS chunks): find and fix

OPS-300High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

Modern sites are built into many small JavaScript files called chunks. Their names often include a hash, such as checkout.3f9a1c.js. The hash changes whenever the code changes. The HTML page lists which chunk names it needs.

A 404 chunk happens when the HTML asks for a file name the server cannot find. The page loads, but the part of the app in that chunk does not. In the browser console you may see ChunkLoadError or Loading chunk 123 failed.

Common causes: the deploy replaced the old files and visitors still hold old HTML; the upload to the server or CDN (content delivery network) was partial; the build used a wrong public path or base URL; or a CDN cached the HTML from one build and the assets from another.

Why it costs you leads or sales

The page looks fine, so nobody notices. But the chunk that failed often holds the form logic, the checkout step, the cookie banner or the tracking code. Visitors click and nothing happens. Ad clicks are paid for, and the conversion never gets recorded.

Where a missing chunk breaks the funnel
  1. Ad clickVisitor lands on the page
  2. HTML loadsPage renders and looks normal
  3. Chunk requestServer returns 404 for the JS file
  4. Form submitButton does nothing
  5. Conversion tagNever fires

The landing page loads, but the script that powers the form never arrives.

Form submissions around a bad deployExample numbers
Form submissions around a bad deploy (example)Before deploy: 40 submissions per day; Chunk missing: 6 submissions per day; After fix: 39 submissions per day0153140639Before deployChunk missingAfter fixsubmissions per day

Example: illustrative numbers showing submissions falling when a chunk is missing and recovering after the fix.

How to check if your site has it

Find missing chunks in your browser
  1. Open the page in a private window

    This avoids your own cache. Use the live URL that ads send traffic to.

  2. Open DevTools and the Network tab

    Press F12 or right-click and choose Inspect. Reload the page.

  3. Filter by JS and look for red 404 rows

    Click the Status column to sort. Any 404 on a .js file is a missing chunk.

  4. Check the Console tab

    Look for ChunkLoadError, Loading chunk failed, or Unexpected token '<'. The last one means the server returned an HTML error page instead of JavaScript.

  5. Walk the funnel

    Click through the form, checkout or booking steps. Chunks are often loaded only when a step opens, so a 404 can appear later.

  6. Test from another network

    A CDN can serve different files in different regions. Try mobile data or a second location.

Check a chunk URL from the command linebash
curl -I https://www.example.com/_next/static/chunks/main-abc123.js
# HTTP/2 404 means the file is missing
# HTTP/2 200 with content-type: application/javascript means it is fine

How to fix it

The exact steps depend on how your site is built and hosted. The goal is the same: every file the HTML names must exist, and old files must stay for a while.

General fix
  1. Identify the missing file name

    Copy the exact URL from the 404 row in the Network tab.

  2. Check whether it exists in your build output

    Look in the build folder (often dist, build, .next/static or public). If it is there, the upload or path is wrong. If it is not, the build is stale or mismatched.

  3. Rebuild from a clean state and redeploy everything

    Delete the build folder, run the build again and upload the whole output, not just changed files.

  4. Keep old assets after a deploy

    Do not delete the previous build's hashed files straight away. Visitors with open tabs or cached HTML still ask for them.

  5. Purge the CDN and HTML cache

    Clear cached HTML so it points to the new file names. Hashed asset files can be cached for a long time, but HTML should not be.

  6. Check the public path

    Make sure the base URL or asset prefix in your build config matches where files are actually served.

Fix by platform
  1. Clear every cache layer

    Purge your caching plugin (for example WP Rocket or W3 Total Cache), the host cache and any CDN. Cached HTML often points to old minified or combined files.

  2. Regenerate minified and combined files

    In your optimisation plugin, clear the minify or combine JS cache so new files are created, then reload the page.

  3. Check theme or plugin updates

    If a theme or plugin update removed files, reinstall it from its source so the full folder is restored.

Cache rules: long for hashed assets, short for HTMLnginx
location ~* \.(js|css)$ {
  add_header Cache-Control "public, max-age=31536000, immutable";
  try_files $uri =404;
}

location / {
  add_header Cache-Control "no-cache";
  try_files $uri /index.html;
}

How to confirm it's fixed

Confirmation checklist
  • Hard reload the live page in a private window and see no 404 rows for .js files in the Network tab
  • The Console shows no ChunkLoadError or Loading chunk failed messages
  • Submit a test lead and confirm it reaches your inbox or CRM
  • Open each funnel step (form, checkout, booking) and confirm it works
  • Check that conversion tags fire, using your tag tool's preview or the Network tab
  • Test again from a second network or region

How to prevent it happening again

Deploy habits

Risky deploy

  • Old build files deleted on release
  • Files uploaded one by one
  • HTML cached for a long time
  • Nobody opens the live site after release

Safe deploy

  • Previous assets kept for a set period
  • Full build switched in at once
  • HTML not cached, assets cached by hash
  • Key journeys tested right after every release
Prevention checklist
  • Add a post-deploy step that requests the main asset URLs and fails on any 404
  • Keep at least the previous builds' hashed files available
  • Purge CDN HTML cache as part of each release
  • Avoid deploying while a large ad budget is running
  • Use a staging check that mirrors the production base URL
  • Run a scheduled test of your real funnels so a break is caught between releases too

How FunnelGuard handles this

FunnelGuard detects this today. A robot visitor runs your real customer journeys on a schedule, such as a lead form, a checkout or a booking button, and checks each step. If a missing chunk stops a form or button from working, or a tracking hit from being sent, the step fails.

A failure is re-checked from a second region before one alert goes out, which helps rule out a one-off glitch. The alert includes a screenshot and a likely cause, and can go to email, Slack, Teams, WhatsApp, a webhook or PagerDuty. You can try it on the Free plan (1 site, 2 journeys, daily checks, no card), and paid plans have a 3-day free trial.

Questions people ask

Why am I getting 404 errors for JavaScript files after a deploy?

Your HTML is asking for hashed file names that are no longer on the server. This usually happens when the deploy deleted old files, the upload was incomplete, or a cache is serving HTML from an older build.

What does 'Loading chunk failed' or ChunkLoadError mean?

The browser tried to load a part of your JavaScript app and the request failed, most often with a 404. The feature in that chunk, such as a form or checkout step, will not work for that visitor.

Why does my page look fine but the form does nothing?

The HTML and CSS can load while the JavaScript chunk that handles the form fails. The page renders normally, but the button has no working code behind it. Check the Network and Console tabs for 404 errors.

How do I fix 404 JS chunks on my live site?

Find the missing file URL in the Network tab, then rebuild and redeploy the full build output. Keep older hashed assets for a while, and purge CDN and HTML caches so pages point to the new files.

Why do I see 'Unexpected token <' in the console after a release?

The server returned an HTML page, often index.html, where the browser expected JavaScript. That means the requested script file was missing and a fallback rule served HTML instead of a 404.

Should I delete old build files after each deploy?

Not immediately. Visitors with open tabs or cached HTML may still request the old hashed files. Keep previous builds' assets for days or weeks and remove them on a schedule.

Can a CDN cause missing JS chunks?

Yes. If the CDN caches old HTML while the origin has only new assets, or the reverse, the page requests files that do not exist. Purge the HTML cache on each release and give HTML a short cache time.

How can I catch missing chunks before customers do?

Test your real journeys after each deploy and on a schedule. A synthetic monitor such as FunnelGuard runs your forms and checkouts and alerts you when a step fails, so you do not have to rely on visitor complaints.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.