[IMP] assets: switch to optimized rjsmin minification

The C implementation of the JS minification gives speedups between 6
and 55 times faster than the regex-based Python port, depending on
how compressed the input it (which is what our default implementation
does).

This is measurable when generating compiled assets bundle from scratch,
e.g. after installing/updating modules or source code.

As an illustration, the minification of a 2MB JS bundle can be 50x
faster:

```py
import rjsmin
from odoo.addons.base.models.assetsbundle import rjsmin as rjsm
js_source = open("web.assets_common_lazy.js").read() # 2MB JS
%timeit rjsm(js_source)
 # -> 339 ms ± 495 µs per loop (mean ± std. dev. of 7 runs, 1 loop each)
%timeit rjsmin.jsmin(js_source)
 # -> 6.88 ms ± 213 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
```

It's also a drop-in replacement, as long as you rjsmin 1.1.0 or better
is available (to support format strings properly, a.o.).

See also the documentation of rjsmin: http://opensource.perlig.de/rjsmin/

closes odoo/odoo#104283

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
Olivier Dony
2023-06-05 16:16:57 +02:00
parent f6814d9c6e
commit 3db7956b4c
7 changed files with 9 additions and 59 deletions
+1
View File
@@ -44,6 +44,7 @@ Depends:
python3-pydot,
python3-openssl,
python3-pypdf2,
python3-rjsmin,
python3-qrcode,
python3-renderpm,
python3-reportlab,