fresh
fresh copied to clipboard
Optimized bundles
Because bundles are generated with esbuild JIT, we can optimize bundles for each browser we are serving content to. For example the bundle shipped to Firefox 88 would need transpilation for private class methods, whereas a bundle shipped to the latest Chrome would not.
Browser version can be determined by User-Agent string. The remaining question is just if this is even a good idea.
I don't think user agent string parsing is a good idea, because it can be spoofed, which may render the bundle broken for that browser. If possible, detecting the specific features in the browser should be used, but it cannot be done server side, of course. Server would need to send a script that checks for the required features, then, based on the browser response, generate a correct bundle.
Also the user agent string is being deprecated anyways so already getting more and more useless.
Though client hints might be a useful alternative.
I don't think user agent string parsing is a good idea, because it can be spoofed, which may render the bundle broken for that browser.
So what? Users don't normally spoof their user agent strings... we can always fall back to serving an "ancient" bundle for browsers which we don't recognize.
Server would need to send a script that checks for the required features, then, based on the browser response, generate a correct bundle.
At minimum this doubles TTI, so it is an unacceptable solution.
Though client hints might be a useful alternative.
When they are more widely supported across engines, yup!
Although client hints still have a long way to go until they are supported in all major browsers, the author of ua-parser-js didn't have anything to say about supporting client hints.
But there's a bright side, it looks like people are willing to help with this.
This one is a really good idea. It would help a lot mobile users not parsing old JS