WEB-19Recommended
Build on HTML that already works
Ship working HTML first. Let JavaScript add behaviour to what is already there.
How to do it
Render all content and links on the server or at build time. Write scripts that find elements and add behaviour to them. If those elements are missing, the script does nothing.
Examples
HTML example
<button class="copy" data-copy="npm install example">Copy</button>
<script type="module">
for (const b of document.querySelectorAll('[data-copy]')) {
b.addEventListener('click', () => navigator.clipboard.writeText(b.dataset.copy));
}
</script>
How to check
A browser driver with JavaScript disabled opens each page type. The main content is present, and every navigation link answers 200.
Measured
On a reference site, rendering the content in the browser instead took mobile Lighthouse Performance from 99 to 85. Layout shift went from 0 to 0.295.
Sources
Related rules
- WEB-222 Keep working when a script or service fails in Website
- WEB-223 Hide buttons that need JavaScript until it runs in Website
- NTF-16 Keep the app working when people say no in Notifications
- CSS-32 Lint every feature against one Baseline target in HTML and CSS
- SEO-6 Send the content in the HTML in SEO
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/site-architecture/progressive-enhancement">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.