Hi all,
Lately I've been playing a lot with PageSpeed Insights improving the performance of my website (with Online Odoo hosting) for SEO purposes and I've come to the point where the file web.assets_frontend_lazy.min.js is the performance bottleneck.
Even though it is supposed to be minified it is heavily unminified. Around line 9787 all the way to the end line, 12278, there is a QWEB code with heavy indentation, lots of extra whitespaces and comments. Why is there a qweb template loaded into a JS variablie in a file that is supposed to be JS minified only... Anyway, the rest of the file seems properly minified with uselful comments left as title to split the code into chunks. That's good.
So, with this in mind I did a test. Downloaded that file (2.4MB !), applied a conservative minifying algorithm eliminating mostly just comments (no uglyfiyng!) and size went down to 2.25MB, and then a bit more by doing some manual whitespacing removal in my script editor for a total savings of let's round it up to 6.5% of file size. (That's a lot for just extra whitespace and comments). Then reuploaded it into the database replacing the original bundle and ran more PageSpeed tests.
My mobile homepage was scoring around 75 with the best score at 79 with about 800ms blocking time. I ran more tests and immediately got multiple results over 80, with the highest at 84 with a blocking time of 530ms. I conclude the results went up by 5 points in performance alone from merely removing comments and whitespace. A massive improvemet.
The point I want to make for the Odoo team is that further minifying that file will heavily increase performance for all users. Keep mind that the browser will stop the page rendering while downloading the brotli compressed web.assets_frontend_lazy.min.js (603kb (default) vs 571kb (modified)), uncompress it, parse the JS (bottleneck is here), execute and render the page.
Further improvements could be made by even removing some legacy functions in that file. Also, archiving some Assets helps to reduce the JS file a bit, however, there are only about 20-30 js assets that can be archived. Way more assets need to be made accesible for end users to archive them.
Thanks!