Core tool
Vite
Bundlers turn source modules and assets into browser-ready production files.
import "./styles.css";
import { createApp } from "./app.js";
createApp(document.querySelector("#app"));
Testing, Tooling & Production
Bundlers turn source modules and assets into browser-ready production files.
Professional JavaScript is not only the code that runs in the browser. It is also the checks, tooling and release habits around that code.
Good tooling gives you confidence to refactor, ship and debug without turning every change into guesswork.
Vite
Tests and tooling reduce fear when changing code.
Consistent structure helps teams and future-you.
Production checks catch issues before users do.
Examples
import "./styles.css";
import { createApp } from "./app.js";
createApp(document.querySelector("#app"));
<script src="one.js"></script> <script src="two.js"></script> <script src="three.js"></script>
Code patterns
Use these examples as a practical bridge from lesson code to maintainable production code.
A cleaner example of the topic.
import "./styles.css";
import { createApp } from "./app.js";
createApp(document.querySelector("#app"));
A habit that does not scale well.
<script src="one.js"></script> <script src="two.js"></script> <script src="three.js"></script>
Tests should read like user behavior when possible.
page.getByRole("button", { name: "Save" });
page.getByRole("status");
Repeatable scripts make releases calmer.
"scripts": {
"check": "npm run lint && npm run test && npm run build"
}
Rules that matter
The browser is only one part of JavaScript work. The workflow around it decides whether the code remains safe to change.
A test should survive harmless refactors.
Unit tests should give quick feedback.
Browser tests are valuable but heavier.
Style debates should not block real work.
Production bundles should be generated and verified.
The build can differ from the dev server.
Production thinking
Testing and tooling protect time. They let you improve code without constantly wondering what broke somewhere else.
Testing with roles and labels naturally pushes code toward accessible markup and user-centered behavior.
Production JavaScript should pass linting, tests, build checks, accessibility checks and basic performance review.
Stable production builds and tested navigation help search engines and users reach content consistently.
Live code lab
The preview runs inside an isolated iframe. The JavaScript is placed inside the HTML editor for now, so every example stays together and remains easy to understand.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these before moving to the next testing and production lesson.
Senior audit upgrade
Use these references when browser support, syntax details or proposal status matters.