When a public page’s script or stylesheet returns 200 but does not take effect, inspect its media type and nosniff contract before changing content or disabling security controls. A response can be readable as bytes yet unacceptable for the resource destination the browser is loading.
The Accept negotiation guide chooses a representation at one URL. This procedure holds the intended script or stylesheet fixed and tests whether the response declares a type appropriate to its browser use.
Use a harmless local page with visible markers. No production policy or unfamiliar code needs to run. The purpose is to distinguish a MIME acceptance failure from an unavailable resource, a challenge page or an unrelated application error.
Apply nosniff to the relevant resource destination
The current MDN X-Content-Type-Options reference describes nosniff behavior, including blocking script and style loads when their declared MIME types are unsuitable. A stylesheet should be served as text/css, and a script needs an appropriate JavaScript MIME type under the applicable browser rules.
Do not remove nosniff as a blanket repair. First correct a demonstrated server or asset-route error. An application fallback may return its HTML shell at a missing .js path;the correct fix is not to persuade the browser to execute that HTML as JavaScript.
Status, media type, body and destination all belong in the receipt. A file extension alone does not establish the declared response type. Conversely, an exact-looking Content-Type cannot prove the body is the intended approved dependency.
Use the complete harmless page and two resources
Serve this fixture from an authorized local HTTP origin. It references only two local resources and requires no authentication, third-party script or live product integration.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Harmless MIME fixture</title>
<link rel="stylesheet" href="/guide.css">
<script src="/mark.js"></script>
</head>
<body><p id="marker">Public setup explanation</p></body>
</html>
The complete /mark.js body is:
document.documentElement.dataset.fixture = 'ready';
The complete /guide.css body is:
#marker { color: rgb(0, 128, 0); }
The script writes only a synthetic DOM marker. The stylesheet changes only the test paragraph’s color. The successful baseline therefore has an observable result without sending messages, submitting forms or changing application data.
Populate the response and outcome matrix
For the approved baseline, the page is text/html, the script is text/javascript, and the stylesheet is text/css. The tested script and style responses carry X-Content-Type-Options:nosniff. Record the actual headers and bytes in the browser network evidence.
| Case | /mark.js response | /guide.css response | Expected markers |
|---|---|---|---|
| Baseline | 200;text/javascript;correct script | 200;text/css;correct style | DOM ready;green paragraph |
| Wrong script type | 200;text/plain;same script bytes | Baseline | No script marker;style still applies |
| Wrong style type | Baseline | 200;text/plain;same CSS bytes | Script ready;green style absent |
| HTML fallback at script URL | 200;text/html;generic HTML body | Baseline | No script marker;wrong resource identified |
Every resource in these cases is served through the controlled local route. Keep the nosniff header fixed while varying the relevant type or fallback body. Changing several policies simultaneously would make the result harder to interpret.
Check the actual DOM and computed style
For each case, load a clean page context and inspect document.documentElement.dataset.fixture. Read the paragraph’s computed color rather than merely searching the stylesheet source for green. Preserve console and network observations as supporting evidence, not the only success criteria.
The baseline should produce ready and rgb(0, 128, 0) under the displayed fixture. In the wrong-script case, the stylesheet can still work. In the wrong-style case, the script can still work. Those independent controls help demonstrate which dependency failed instead of calling the entire page broken.
Start a fresh context or reset the fixture between cases. A previously executed script can leave its DOM marker behind, and a cached stylesheet can preserve a prior appearance. An old green paragraph is not evidence that the newly declared type was accepted.
Classify the failure before changing a policy
A CSP violation concerns a policy restricting a source or operation. A CORS failure concerns browser cross-origin access. A documented WAF challenge substitutes a different response. A MIME failure concerns the declared type and resource destination. They can coexist, but they need separate evidence.
Use the CSP dependency investigation when a policy violation is implicated. Use the challenge fingerprint method when HTML arrives instead of the expected data or asset. Do not assume text/html proves a challenge without the relevant marker and owning-layer evidence.
The exact local fixture is same-origin to isolate MIME behavior. Extending it to another origin introduces other requirements. Record those explicitly rather than interpreting a cross-origin failure as a contradictory MIME result.
Trace the wrong type to its producer
Find the actual route, storage metadata, server mapping or intermediary that sets Content-Type. A source file can have the correct .css extension while an object-storage record serves it as text/plain. A shared application fallback can also answer every missing resource with successful HTML.
Repair the responsible producer and verify the actual public response through the ordinary route. A local server configuration change is not evidence that the CDN now emits the same header. Keep source configuration and observed delivery separate.
Retain the wrong-type and fallback negatives in regression checks. They should fail the meaningful marker assertions even when the network still reports 200. An audit that only counts successful statuses would miss the original problem.
Release the intended execution contract
The final receipt should include the harmless fixture, resource bytes, exact response fields, browser context, marker results and generating-layer repair. Preserve security controls unless the responsible owner approves a separately justified change.
Close when the intended public dependencies have appropriate declared types and the expected visible behavior occurs under the tested contract. A successful MIME test does not establish that all application logic works or that a search engine has rendered or indexed the page.
The concrete result is an explainable relationship between requested resource, delivered representation and browser behavior. It lets the engineering owner fix a real dependency defect without turning off a useful response safeguard to silence the symptom.
