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.
- Ad clickVisitor lands on the page
- HTML loadsPage renders and looks normal
- Chunk requestServer returns 404 for the JS file
- Form submitButton does nothing
- Conversion tagNever fires
The landing page loads, but the script that powers the form never arrives.
Example: illustrative numbers showing submissions falling when a chunk is missing and recovering after the fix.
How to check if your site has it
Open the page in a private window
This avoids your own cache. Use the live URL that ads send traffic to.
Open DevTools and the Network tab
Press F12 or right-click and choose Inspect. Reload the page.
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.
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.
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.
Test from another network
A CDN can serve different files in different regions. Try mobile data or a second location.
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 fineHow 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.
Identify the missing file name
Copy the exact URL from the 404 row in the Network tab.
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.
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.
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.
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.
Check the public path
Make sure the base URL or asset prefix in your build config matches where files are actually served.
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.
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.
Check theme or plugin updates
If a theme or plugin update removed files, reinstall it from its source so the full folder is restored.
Check the theme assets
In Online Store > Themes > Edit code, open the Assets folder and confirm the JS file named in the 404 is there.
Fix the reference
If a file was deleted or renamed, update the script tag in theme.liquid or the section that references it, or restore the file from a previous theme version.
Publish a working theme version
If the problem came from an edit, republish the last working theme from the theme library.
Check custom HTML tags
Open Tags and look for Custom HTML tags that load scripts from your own domain. A 404 there means the script URL is outdated.
Update the URL and republish
Fix the script address in the tag, test it in Preview mode, then Submit and publish the container.
Check custom code URLs
In Project settings > Custom code and in page settings, check any script src that points to a file you host elsewhere.
Republish the site
Publish again to all domains so the generated pages and hosted assets match.
Check custom JS and external script links
In the funnel or website settings, look at tracking code and custom code sections for script URLs that now return 404.
Re-save and republish the page
Fix the link, save, and publish the funnel step again.
Check custom code
In Settings > Custom code, check each snippet that loads an external script, and fix any URL that returns 404.
Publish again
Publish the site so the live version uses the corrected code.
Check code injection
In Settings > Advanced > Code injection, look for script tags that load files from a URL that no longer exists.
Replace or remove the broken reference
Point it to a working file, save, and reload the live page.
Deploy the full build atomically
Upload the whole build to a new folder, then switch traffic to it, instead of overwriting files one by one.
Keep the last few builds' assets
Retain hashed files from earlier releases for days or weeks. Remove them only on a schedule.
Set cache headers correctly
Give hashed assets a long cache time and HTML a short one or no-cache, as in the snippet below.
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
- 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
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
- 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.
Related issues
- OPS-292Deploy broke landing page or formFix guide
- OPS-293Deploy removed tracking snippetFix guide
- OPS-294Rollback needed but no previous versionFix guide
- OPS-301Old cached service worker serving outdated appFix guide
- OPS-299Environment variable missing after redeployFix guide
- OPS-308Deploys during peak ad hoursFix guide