JavaScript
Make websites more useful with JavaScript. Browser APIs, lightweight interactions, practical code examples, and solutions without unnecessary dependencies.
Browse 14 articles in this topic. View all topics.
- Getting Form Data With the FormData API
Use FormData to collect named form fields, inspect values, handle checkboxes and files, and send data with fetch while keeping normal form submission.
- requestSubmit() vs submit(): validation and events
Compare requestSubmit() and submit() for JavaScript form submission. Keep browser validation and submit events, and choose which button submits the form.
- JavaScript Module Scripts Are Deferred by Default
JavaScript module scripts are deferred by default. Use imports and head entry points, understand async exceptions, and distinguish parsing from readiness.
- defer, async, and type="module": How Scripts Actually Load
Compare defer, async, and type="module" script loading. Choose execution timing for DOM access and dependencies, including inline scripts and their limits.
- A Progressive Enhancement Pattern With Custom Elements
A progressive enhancement pattern with custom elements: add a password visibility button after setup, keep the native field, and avoid duplicate controls.
- Web Components Make More Sense When They Enhance HTML
Use Web Components to enhance working HTML. Build an optional word counter, preserve native form behaviour, and handle setup when an element reconnects.
- Keeping a Website Usable When JavaScript Fails
Build content, navigation, and forms on working HTML so one failed script removes an enhancement instead of the whole page.
- How Much JavaScript Does a Website Really Need?
Start with the page's job, use the browser's native features, and add JavaScript only where its behaviour justifies the cost.
- Building a modal with HTML dialog
Build modal windows from the native HTML dialog element, including backdrops, forms, Escape handling, and practical examples.
- Native HTML and CSS Features That Replaced JavaScript
Choose native HTML and CSS before custom JavaScript. Compare dialogs and popovers, then use native forms and layout rules without rebuilding behaviour.
- How Third-Party Scripts Slow Down Websites
See how analytics, ads, chat widgets, embeds, and other third-party scripts affect loading, privacy, and reliability.
- Start TypeScript With the Code You Already Have
A practical introduction to TypeScript types, narrowing, functions, API boundaries, and a small project setup.
- Social sharing buttons without JavaScript
Add lightweight sharing links for social networks and email without loading third-party JavaScript.
- Making a device vibrate from a web page
Trigger a short vibration or vibration pattern from JavaScript with the Vibration API.