THE GITHTML FIELD GUIDE
Why module scripts behave differently in file-based HTML
Module scripts use loading and origin rules that can make a file-based document behave differently from a hosted application. Check module imports and resource responses, but do not expect enabling JavaScript alone to reproduce a server environment. A portable reading copy should contain its essential content without requiring the application's module graph to execute.
Identify the specific failure
A module entry point may import many other files, each with its own path and MIME requirements. Saving one HTML file does not save that graph. Local file origins can also behave differently from ordinary HTTP origins.
Make a narrow correction
Use the original hosted environment for features that genuinely require an application. For a static document, export the rendered explanation, data, and figures instead of carrying an empty application shell. Avoid weakening cross-origin checks to force a file-based preview.
- Identify the module entry point and the imported resources it requires.
- Separate a development preview problem from the need for a portable reading artifact.
- Ask for static essential content rather than a workaround that relaxes browser protections.
<main><h1>Results</h1><p>Include the actual result here, not only an application mount point.</p></main>Follow the module graph instead of copying only the entry point
An illustrative report contains index.html, a module entry point called report.js, and a separate chart renderer imported by report.js. Copying the first two files leaves the third dependency unresolved. The entry script can be present and correctly named while the application still cannot render its results. Inspect the first failed import and its resolved location, then follow the dependency chain only as far as needed to understand the failure. Do not assume that a single missing-file correction proves that every later import or data request will work.
Module loading also checks the resource type. A server that returns HTML for a missing JavaScript path can produce a module MIME error rather than an ordinary-looking missing page. Changing .js to .mjs does not repair an HTML response; the browser needs the intended JavaScript bytes with an appropriate type. Keep this separate from an execution error inside successfully loaded code. The console's first meaningful failure and the corresponding network response are more useful than a long list of later errors caused by the absent renderer.
If the document's purpose is reading, inventory what the renderer was supposed to produce: a result table, a chart, explanatory labels, and perhaps a filter summary. Ask the publisher to preserve those outputs in ordinary HTML or reviewed static assets. The exported copy should state the selected filter and observation time rather than pretending to retain live application behavior. This does not fix the hosted application's module setup, and it should not be presented as doing so. It creates a separate reading artifact whose usefulness no longer depends on reproducing the original execution environment.
Verify the repaired artifact
Turn scripts off and inspect whether any substantive content remains. A title and spinner are not a complete reading artifact.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.