Agent Wranglers

Site architecture Required

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.

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

Turn JavaScript off. Every page and link still works.

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.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/site-architecture/progressive-enhancement.