🏎️ The History Of Javascript Performance Vol 1

Tom Smykowski
6 min readApr 11, 2023

From handling an input to running a game, Javascript went a long road to answer the question who runs the Web.

Javascript performance improved significantly during last years. From this article you will learn about several ways browser Javascript engines developers boosted Javascript performance.

#1 Faster Revisits With JavaScript Startup Bytecode Cache

Firefox relies on a Javascript engine called SpiderMoney. In 2017 it was modified to significantly improved repetitive startups of a website.

Usually, when you visit a page, the browser caches Javascript code. Thanks to that, when revisiting, browser can utilize the cached version of Javascript code rather than downloading it again from the Internet.

With current Internet speeds it may not sound like an expective task. But we have to take into account it’s not trivial. It may involve resolving a domain, making a SSL handshake, negotiating CORS with preflights and downloading actual Javascript code.

All of the network activities come with a latency penalty dependant on the network routing quality adding from 10-1000ms to the whole process.

Downloading Javascript takes toll too on the responsiveness, because significant portion of Javascript code is not used during startup of a page (it may be anything between 70-90% of the code) but has to be downloaded again on revisit or refresh.

It means that caching Javascript on the user’s device makes a lot of sense.

Firefox cached Javascript for years. It’s nothing new. But in 2017 the developers of the browser father of the modern web went further.

They realized checking Javascript for syntax errors and actually parsing the code is expensive.

The browser has to do it every time, even with cached Javascript, to prepare bytecode, a standardized set of instructions that is later compiled to the machine code.

So, why not cache bytecode too? They did it by caching bytecode in the network cache.

--

--

Tom Smykowski

I will be able to write the next article when 9 people will become a member. Become a member now: https://medium.com/membership/@tomaszs2