Agent Wranglers

When things break Recommended

Keep working when a script or service fails

When a script, a font or another company's service fails at runtime, the page still shows its content and its main actions still work.

How to do it

Build on progressive enhancement, so plain HTML already works. Test that a browser feature exists before using it. Load third-party scripts with async and a time limit, and catch their errors. Give script-only widgets a <noscript> text and a plain link to do the same job.

Example

<a href="/contact" class="open-chat">Contact us</a>
<noscript><p>The booking calendar needs JavaScript. You can also email book@example.com.</p></noscript>
<script type="module">
  if ('clipboard' in navigator) document.body.classList.add('can-copy');
  import('https://chat.example.net/widget.js').catch(() => document.body.classList.add('chat-down'));
</script>

How to check

In the browser's developer tools, block each third-party domain and then the main script. Each page still shows its content and its main links, with no uncaught errors.

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/when-things-break/graceful-degradation.