Skip to content

Instantly share code, notes, and snippets.

@flaan4me
flaan4me / safari-nomodule.js
Created April 26, 2025 20:41 — forked from samthor/safari-nomodule.js
Safari 10.1 `nomodule` support
// UPDATE: In 2023, you should probably stop using this! The narrow version of Safari that
// does not support `nomodule` is probably not being used anywhere. The code below is left
// for posterity.
/**
* Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will
* load <script nomodule> anyway. This snippet solve this problem, but only for script
* tags that load external code, e.g.: <script nomodule src="nomodule.js"></script>
*
* Again: this will **not** prevent inline script, e.g.:
@flaan4me
flaan4me / safari-nomodule.html
Created April 26, 2025 20:39 — forked from anilanar/safari-nomodule.html
Safari 10.1 `nomodule` support
<!--
Similar to https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc
But prevents Safari 10.1 from downloading ES5 scripts.
This is the only way I know to detect "module" support in <head>.
-->
<script>
// matrix of script sources. rows will be executed in order.
// first column is ES6, the second is ES5.
window.__SCRIPTS__ = [