ESM loader quirks, path/URL differences
Resolve URLs safely, understand relative vs bare specifiers, and see how file URLs differ from web URLs. Tiny, runnable demos.
Big picture
Goal: Resolve paths safely across environments.
- Use the URL constructor to resolve relatives
- Know relative vs bare specifiers
- See file: vs https: differences
- Avoid fragile string joins for paths

Relative against base
new URL(relative, base) handles path pieces and slashes correctly.
// Use URL to resolve "./" against a base
const base = "https://site.com/app/screens/";
const img = new URL("./images/icon.png", base);
console.log("resolved:", img.href);
All lessons in this course
- Globals, fetch availability, file/network APIs
- ESM loader quirks, path/URL differences
- Env variables & config patterns