Page MenuHomePhabricator

Use a minified version of the 'pako' library
Closed, ResolvedPublic

Description

ResourceLoader's JS minifier (Wikimedia-Minify) doesn't minify code as efficiently as other minifiers (since it needs to be fast enough to execute on-the-fly). We could benefit from using the pre-minified versions of some external libraries, instead of letting our minifier minify them on-the-fly. We already do this for Vue.js and some related libraries. Note that we must still include the non-minified version alongside (see T217351, T257878).

Benefits:

  • Smaller transfer size

Drawbacks:

  • Increased effort when upgrading (should be minimal for libraries that we treat as foreign resources, where upgrading is mostly automated)
  • Losing support for source maps, which was just implemented in T47514 (shouldn't be a big deal for most libraries that aren't often involved in production errors)

In this task I'd like to do this for the 'pako' library as an experiment and as an example. Other libraries might be worth doing too, but probably need case-by-case review.

This task is inspired by this comment:

Side note: this is something for another task (which maybe already exists? please link if so), MediaWiki includes third-party JS libraries and uses, at least in case of Pako, the non-minified variant. Resourceloader doesn't minify it as efficiently as the pre-minified variant which has obfuscated (shorter) variable names. All I'm saying is: low hanging fruit?

Event Timeline

Change 956477 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] Use the minified version of the 'pako' library

https://gerrit.wikimedia.org/r/956477

This reduces the transfer size of the 'mediawiki.deflate' module as follows:

BeforeAfter
Without GZIP45.43 kB27.36 kB
With GZIP12.27 kB9.42 kB

For a single library that is loaded by many users as it's required for VE I think those are some nice savings on both traffic and localStorage. Thank you. :-)

If I remember correctly part of the reason why the pre-minified version is smaller is because the developer knows exactly which variable/key names can be obfuscated and which can't. Any "generic" minifier that doesn't have that information has to preserve more.

Change 956477 merged by jenkins-bot:

[mediawiki/core@master] Use the minified version of the 'pako' library

https://gerrit.wikimedia.org/r/956477

matmarex claimed this task.
matmarex removed a project: Patch-For-Review.