logo

blog

My website can't be that messy, right? git clone https://anongit.hacktivis.me/git/blog.git/

no-noscript-element.xml (3592B)


  1. <entry>
  2. <title>The &lt;noscript&gt; element as a trap</title>
  3. <link rel="alternate" type="text/html" href="https://hacktivis.me/articles/no-noscript-element"/>
  4. <id>https://hacktivis.me/articles/no-noscript-element</id>
  5. <published>2025-08-18T11:52:43Z</published>
  6. <updated>2025-08-18T11:52:43Z</updated>
  7. <!--
  8. <link rel="external replies" type="application/activity+json" href="https://queer.hacktivis.me/objects/50be9d37-dee6-4c69-818e-013fa3b010d0" />
  9. <link rel="external replies" type="text/html" href="https://queer.hacktivis.me/objects/50be9d37-dee6-4c69-818e-013fa3b010d0" />
  10. -->
  11. <content type="xhtml">
  12. <div xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" class="h-entry">
  13. <p>
  14. One of the few traps of the web is how the <code>&lt;noscript&gt;</code>
  15. element doesn't provides the right behavior.
  16. </p>
  17. <p>
  18. Definition: The <code>&lt;noscript&gt;</code> element provides alternate content when JavaScript is entirely toggled off or entirely unsupported.<br />
  19. Sources:
  20. <ul>
  21. <li><a href="https://www.w3.org/TR/html4/interact/scripts.html#h-18.3.1">HTML4 § 18.3.1 The NOSCRIPT element</a> with ignoring non-JavaScript in <code>&lt;script&gt;</code> (W3C gives Tcl as example, I'd more point to JScript and VBScript, both of which are thankfully gone)</li>
  22. <li><a href="https://html.spec.whatwg.org/multipage/scripting.html#the-noscript-element">WHATWG HTML (multipage) § The noscript element</a></li>
  23. </ul>
  24. </p>
  25. <p>
  26. While the way to obtain the right behavior is to have a generic
  27. textual element being updated/deleted by your own script using
  28. the DOM APIs.
  29. You could also make the scripts so optional for you
  30. to not need to provide a failure message,
  31. but that's not the right method when the scripts are
  32. needed for actually using the webpage.
  33. </p>
  34. <p>
  35. And should be noted that WHATWG HTML contains a similar recommendation to the latter method:
  36. <blockquote>
  37. The <code>noscript</code> element is a blunt instrument. Sometimes, scripts might
  38. be enabled, but for some reason the page's script might fail.
  39. For this reason, it's generally better to avoid using <code>noscript</code>,
  40. and to instead design the script to change the page from being
  41. a scriptless page to a scripted page on the fly, […]
  42. </blockquote>
  43. </p>
  44. <p>
  45. Because the problem is, JavaScript can fail to load in several ways. Here's a non-exhaustive list of cases:
  46. <ul>
  47. <li>Blocked domains/URLs, think adblockers/anti-viruses or corporate firewalls</li>
  48. <li>Blocked browsers/users, think hosting-side firewall (at any of the IP/TCP/HTTP/… level of encapsulation) which can be legitimate, over-zealous, or accidental</li>
  49. <li>Basic connectivity issues, after all browsing using mobile data is usual, HTTPS configurations still routinely presents expired certificates, BGP/DNS/… still fails</li>
  50. <li>Unsupported APIs or even language syntax, either due to a browser not supporting bleeding edge features or non-portable features</li>
  51. <li>Badly restored website backup or incomplete one</li>
  52. <li>Badly deployed website update, think HTML updated before JavaScript or even an incomplete deployment</li>
  53. <li>Part of the hosting infrastructure being down or overloaded</li>
  54. <li>Limits from the hoster, like rate-limits or limits on total bandwidth</li>
  55. </ul>
  56. I see most of the above on a regular basis, about multiple times per week to few times a month, and I tend to browse simple websites.
  57. And that's without counting the various ways scripts tend to fail at properly handling errors.
  58. </p>
  59. </div>
  60. </content>
  61. </entry>