Is the module/nomodule bridge worth it? (#note)

The support for ES modules <script type="module"></script> is quite good these days. Browsers that support them are also able to deal with modern JavaScript (arrow functions, let/const, …). That’s cool, becau…

The support for ES modules <script type="module"></script> is quite good these days. Browsers that support them are also able to deal with modern JavaScript (arrow functions, let/const, …). That’s cool, because you can include fewer JavaScript polyfills in your ES modules.

To make that work, you have to generate two versions of your source code. One version loads as a "normal script", it targets older browsers and includes a lot of polyfills.

The second version loads as an EcmaScript module. It targets evergreen browsers and includes more or less recent JavaScript syntax.

<!-- do not include polyfills -->
<script src="evergreen.js" type="module"></script>
<!-- ship lots of polyfills and babel magic -->
<script src="old.js" type="nomodule"></script>

I’m digging this approach! Jason Miller released a nice tool called "Worth it". It helps you to figure out what the savings are when shipping "unpolyfilled bundles". It’s fascinating and worth a look! The savings are not as big as I expected them to be. Maybe the module/nomodule bridge is not worth it for your site after all?



Worth it application showing 7% savings thanks to module/nomodule



Reply to Stefan


Print Share Comment Cite Upload Translate
APA
Stefan Judis | Sciencx (2024-03-29T07:57:30+00:00) » Is the module/nomodule bridge worth it? (#note). Retrieved from https://www.scien.cx/2020/03/16/is-the-module-nomodule-bridge-worth-it-note/.
MLA
" » Is the module/nomodule bridge worth it? (#note)." Stefan Judis | Sciencx - Monday March 16, 2020, https://www.scien.cx/2020/03/16/is-the-module-nomodule-bridge-worth-it-note/
HARVARD
Stefan Judis | Sciencx Monday March 16, 2020 » Is the module/nomodule bridge worth it? (#note)., viewed 2024-03-29T07:57:30+00:00,<https://www.scien.cx/2020/03/16/is-the-module-nomodule-bridge-worth-it-note/>
VANCOUVER
Stefan Judis | Sciencx - » Is the module/nomodule bridge worth it? (#note). [Internet]. [Accessed 2024-03-29T07:57:30+00:00]. Available from: https://www.scien.cx/2020/03/16/is-the-module-nomodule-bridge-worth-it-note/
CHICAGO
" » Is the module/nomodule bridge worth it? (#note)." Stefan Judis | Sciencx - Accessed 2024-03-29T07:57:30+00:00. https://www.scien.cx/2020/03/16/is-the-module-nomodule-bridge-worth-it-note/
IEEE
" » Is the module/nomodule bridge worth it? (#note)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2020/03/16/is-the-module-nomodule-bridge-worth-it-note/. [Accessed: 2024-03-29T07:57:30+00:00]
rf:citation
» Is the module/nomodule bridge worth it? (#note) | Stefan Judis | Sciencx | https://www.scien.cx/2020/03/16/is-the-module-nomodule-bridge-worth-it-note/ | 2024-03-29T07:57:30+00:00
https://github.com/addpipe/simple-recorderjs-demo