Deploying ES2015+ Code in Production Today — Philip Walton
The reality is transpiling and including polyfills is quickly becoming the new norm. What’s unfortunate is this means billions of users are getting trillions of bytes sent over the wire unnecessarily to browsers that would have been perfectly capable of running the untranspiled code natively.
Phil has a solution: serve up your modern JavaScript using script type="module"
and put your transpiled fallback in script nomodule
.
Most developers think of
<script type="module">
as way to load ES modules (and of course this is true), but<script type="module">
also has a more immediate and practical use-case—loading regular JavaScript files with ES2015+ features and knowing the browser can handle it!