An app that looks fine but its buttons do nothing
A page that renders but whose buttons, sliders and links do nothing is usually a page whose JavaScript never ran. The HTML was already on the page — pre-rendered at build time or server-rendered — so it looks complete. The script that makes it interactive was not loaded, or was loaded as the wrong kind of file.
What it looks like
- The layout, text and images are all there.
- Clicking a button does nothing: no navigation, no spinner, no error dialog.
- Controls that the browser itself draws, like a slider, may still move — but nothing else on the page reacts.
- The browser console shows a syntax error, and the token it complains
about is
<. - The Network tab shows the main script request answered with an HTML page instead of a script.
1. Read the console first
Open the browser's developer tools and look at the console.
"Unexpected token" is the parser saying it met something it cannot read
at that position (MDN:
SyntaxError: Unexpected token, checked 2026-11-06). When the first
character of the file is <, the browser was handed an
HTML document where it expected JavaScript — for example the site's 404
page or the home page.
The error names the script, not the bug. The bug is on the server, in whatever answered that request.
2. Ask the server what it returned for the script
Take the script's URL from the error or from the Network tab, then request it directly:
curl -I https://example.com/assets/app-abc123.jsRead two things in the response:
- Status. A
200is what you want. A301,302or307means some rule is sending the file request somewhere else. - Content-Type. For a
.jsfile it should be a JavaScript type; the common types table on MDN liststext/javascript(MDN: Common MIME types, checked 2026-11-06). A Content-Type oftext/htmlconfirms the server answered with a page.
If the response has X-Content-Type-Options: nosniff, a
script served with an HTML type is blocked before it is even parsed;
without that header the browser tries to parse the HTML as JavaScript
and fails at the first character (MDN:
X-Content-Type-Options, checked 2026-11-06).
3. Find the rule that did it
The usual causes, in order of how often they turn up:
- A single-page-app fallback. Every path the static
server cannot find is answered with
index.html. That is right for page URLs such as/plansand wrong for/assets/app-abc123.js. - A redirect for old or moved pages. A rule written
for a page path that no longer exists can match a folder of the same
name. A rule for
/assetsor/staticthen catches every file under it. - The file is simply missing from the host, and the
fallback from point 1 hides the miss behind a
200page.
Match rules against the whole path, not just the first segment:
/assets/app.js is both "under /assets" and "a
file", and the second fact must win.
4. Fix it at the server, not in the app
- Serve real files before any fallback. Check the
disk (or object storage) first, and only rewrite to
index.htmlwhen nothing was found. - Only rewrite page URLs. Skip any request whose last path segment contains a dot, since that is a file request, not a page.
- Never redirect a file request to an HTML page. If a redirect list is meant for retired pages, apply it only to requests that look like pages.
The same rule applies in reverse proxies, CDN rules and serverless rewrites: the asset path has to be excluded from the catch-all before it is excluded from anything else.
5. Check that it is fixed
curl -Ion the script returns200and a JavaScript Content-Type.- The console is clean on a hard reload (bypass the cache).
- The buttons, forms and other controls respond.
Why the page looked fine all along
Pre-rendering — turning each page into static HTML at build time — is there for speed and for search engines, and it does its job even when the JavaScript is broken. The markup arrives complete, so the page paints. Only interaction shows the difference.
Pre-rendered markup can also show browser defaults where an app value
belongs. A range input with no value attribute shows the
halfway point between its minimum and maximum (MDN:
<input type="range">, checked 2026-11-06); a
slider parked in the middle while the page around it says something else
is a second clue that no script has run.
Related pages
- From idea to deployed AI app: where the deploy and its checks fit
- The cloud, for AI apps: what the host does with static files
- Security for AI apps and agents
See also
Glossary terms used on this page: Host, Serverless, Token, Tool.
Sources
All checked on 2026-11-06.
- MDN, SyntaxError: Unexpected token
- MDN, Common MIME types
- MDN, X-Content-Type-Options
- MDN, <input type="range">
First version written with AI assistance, from a deployment bug where a redirect rule for retired pages also matched the folder that holds the site's JavaScript, and checked against the sources on 2026-11-06. Found a mistake? Fix it or open an issue. Text licensed under CC BY 4.0.