Is Legacy JavaScript worth it?

Is Legacy JavaScript worth it?

Recently I came across this video which illustrated the problem with Legacy Javascript.

95% of global web traffic comes from browsers that support the most widely used JavaScript language features introduced recently, such as Classes, Arrow functions, Destructuring, Rest and spread parameters (ES2015), Async/await (ES2017).

This means that supporting the remaining 5% of the browser market (IE 11, etc...) requires transpiling to Legacy Javascript syntax, which most developers do, but it incurs a cost.

Besides de obvious performance issues of transpiling increasing the filesize and number of instructions created. According to the video I linked, a very rough estimation measured an extra 80 Petabytes / month of unneeded Legacy Javascript, which translates to 54,000 metric tons of CO2 emissions, that take 37 Million trees to be offset. That's a lot of trees for some lines of code.

ES2017 has the widest range of browser compatibility while including most of the commonly used modern syntax features. So transpiling code to ES2017 is the best target you can aim for in terms of cost/browser support.

Luckily there's a way to support legacy Javascript without sacrificing performance, by making sure that only transpiled code is used for browsers that actually need it, as shown below:

ModernVSLegacyJS.png

If you wanna make sure you are using Javascript efficiently, EStimator.dev is a simple tool that calculates the size and performance improvement a site could achieve by delivering modern JavaScript syntax.

estimator-screenshot.png

 
Share this