Split browser code into explicit dependencies.
- type=module
- import
- export
- module scope
A module has its own scope and can import or export bindings. The browser loads module dependencies by URL; serve examples over localhost because file URLs can have module loading restrictions. Modules run in strict mode and are deferred by default. Keep each module focused on one responsibility.
A script without type=module cannot use import syntax in the browser.
Split a formatter and a page entry point into two files and run them through a local server.
Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.
- Explain the core idea in your own words without reading the code.
- Change one input and predict the output before running it.
- Test one boundary or failure case, then record what you changed.
Run python3 -m http.server 8000 from the JavaScripts folder, then open this lesson through http://localhost:8000/. Fetch, modules, storage, history, and workers can behave differently or fail under file URLs.