popcodeorg / popcode

An HTML/CSS/JavaScript editor for use in the classroom
MIT License
189 stars 138 forks source link

Load modern ES bundle in modern browsers #1618

Open outoftime opened 5 years ago

outoftime commented 5 years ago

It seems to be becoming fairly common practice to generate two versions of an application’s JavaScript bundle: one that retains most of the features and syntax of modern JavaScript, and a second that compiles down to pure ES5 for maximum compatibility. There’s a slightly hacky but ultimately quite simple way to make sure the right bundle flavor is loaded, by using <script type="module"> and nomodule respectively.

We should explore setting things up this way in Popcode. I think it would mostly be worth the extra complexity if the modern JS bundle were substantially smaller than the legacy bundle, so worth investigating that first.

outoftime commented 5 years ago

Another potential argument would be if modern browsers were able to execute modern ES meaningfully more efficiently—I have not seen any benchmarks one way or another but it seems intuitively possible.