QuickDevGuide

Home › JavaScript

Modules (import / export) — JavaScript

ES modules split code into files with explicit dependencies. Each module has its own scope, runs in strict mode and is evaluated once (then cached). Export styles Named exports — many per file, imported by exact name: export const sum = … / import { sum } from "./math.js". Default export — one per file, imported with any name: export default class Logger / import Logger from "./logger.js". Prefer named exports in libraries and shared code — they are easier to refactor and auto-import. Dynamic import await import("./heavy.js") loads a module on demand, returning a promise. Bundlers (Vite, webpack) turn this into a separate chunk — exactly how this site lazy-loads each course. In the browser Use <script type="module" src="main.js">. Module scripts are deferred, use CORS, and require full…

Key Takeaways