Towards a JavaScript Binary AST
One of my main concerns with this proposal, is the increasing complexity of what was once a very accessible web platform. You have this ever increasing tooling knowledge you need to develop, and with something like this it would certainly increase as &quot;fast JS&quot; would require you to know what a compiler is. Sure, a good counterpoint is that it <i>may</i> be incremental knowledge you can pick up, but I still think a no-work make everything faster solution would be better.<p>I believe there exists such a no-work alternative to the first-run problem, which I attempted to explain on Twitter, but its not really the greatest platform to do so, so I&#x27;ll attempt to do so again here. Basically, given a script tag:<p><pre><code>    &lt;script src = &quot;abc.com&#x2F;script.js&quot; integrity=&quot;sha256-123&quot;&gt;&lt;&#x2F;script&gt;
</code></pre>
A browser, such as Chrome, would kick off <i>two</i> requests, one to abc.com&#x2F;script.js, and another to cdn.chrome.com&#x2F;sha256-123&#x2F;abc.com&#x2F;script.js. The second request is for a pre-compiled and cached version of the script (the binary ast). If it doesn&#x27;t exist yet, the cdn itself will download it, compile it, and cache it. For everyone except the first person to ever load this script, the second request returns before the time it takes for the first to finish + parse. Basically, the FIRST person to ever see this script online, takes the hit for everyone, since it alerts the &quot;compile server&quot; of its existence, afterwards its cached forever and fast for every other visitor on the web (that uses chrome). (I have later expanded on this to have interesting security additions as well -- there&#x27;s a way this can be done such that the browser does the first compile and saves an encrypted version on the chrome cdn, such that google never sees the initial script and only people with access to the initial script can decrypt it). To clarify, this solution addresses the exact same concerns as the binary AST issue. The pros to this approach in my opinion are:<p>1. No extra work on the side of the developer. All the benefits described in the above article are just free without any new tooling.<p>2. It might actually be FASTER than the above example, since cdn.chrome.com may be way faster than wherever the user is hosting their binary AST.<p>3. The cdn can initially use the same sort of binary AST as the &quot;compile result&quot;, but this gives the browser flexibility to do a full compile to JIT code instead, allowing different browsers to test different levels of compiles to cache globally.<p>4. This would be an excellent way to generate lots of data before deciding to create another public facing technology people have to learn - real world results have proven to be hard to predict in JS performance.<p>5. Much less complex to do things like dynamically assembling scripts (like for dynamic loading of SPA pages) - since the user doesn&#x27;t also have to put a binary ast compiler in their pipeline: you get binary-ification for free.<p>The main con is that it makes browser development even harder to break into, since if this is done right it would be a large competitive advantage and requires a browser vendor to now host a cdn essentially. I don&#x27;t think this is that big a deal given how hard it already is to get a new browser out there, and the advantages from getting browsers to compete on compile targets makes up for it in my opinion.