Is the module/nomodule bridge worth it?
- Published at
- Updated at
- Reading time
The support for 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.
<!-- 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?
- The navigation timing API includes the type of the current navigation
- Define where an element should be scrolled to using elem.scrollIntoView
- requestSubmit offers a way to validate a form before submitting it
- Optional chaining helps to avoid "undefined is not a function" exceptions