JavaScript for Frontend Performances
JavaScript performance work reduces how much code is downloaded, parsed and executed. Techniques include code splitting, tree shaking, removing unused dependencies, and keeping the main thread free by breaking long tasks, deferring non-urgent work and moving heavy computation to web workers.
Stage: Runtime · Part of the Frontend Performance roadmap · Last reviewed 19 November 2026
What to learn in JavaScript
- Find large dependencies with a bundle analyser and replace or drop them
- Split routes and heavy components with dynamic import
- Break a long task into chunks using scheduler or setTimeout yielding
- Move expensive computation into a web worker
- Explain why parse and execute cost matters more than download size
JavaScript interview questions
What is tree shaking and what can stop it working?
Tree shaking removes exports that nothing imports, using the static structure of ES modules. It fails with CommonJS modules, side-effectful imports not marked in package.json sideEffects, or code that touches the module in dynamic ways.
What counts as a long task and why does it matter?
A long task is main-thread work that runs for more than 50 milliseconds without yielding. While it runs the browser cannot respond to clicks or paint, so long tasks directly hurt Interaction to Next Paint and make the page feel frozen.
Where JavaScript fits in the Frontend Performance roadmap
JavaScript belongs to the Runtime stage (intermediate level), which takes about 10 hours. Keep it smooth.
Other units in this stage
Back to the full Frontend Performance roadmap