Page MenuHomeSoftware Heritage

assets: Upgrade MathJax to 3.x and bundle it with webpack
ClosedPublic

Authored by anlambert on Apr 10 2020, 3:34 PM.

Details

Summary

A new major version of MathJax typesetter has been recently released which
now enables to properly bundle the library with webpack.

So remove previous CDN use to get MathJax and use a self hosted version from
now on.

Related to T1680

Test Plan

There is already a cypress test to check math typesetting in notebook rendering.

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D3009 (id=10677)

Rebasing onto 0503cce23f...

Current branch diff-target is up to date.
Changes applied before test
commit 6573e07fdbfd8b9028822ca6b71fadcd056ef550
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Fri Apr 10 15:29:41 2020 +0200

    assets: Upgrade MathJax to 3.x and bundle it with webpack
    
    A new major version of MathJax typesetter has been recently released which
    now enables to properly bundle the library with webpack.
    
    So remove previous CDN use to get MathJax and use a self hosted version from
    now on.
    
    Closes T1680

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/57/ for more details.

MathJax is a very big library :/

Is it really worth it?

Btw, is it loaded all the time, or just when needed to show a file?

Is it really worth it?

Yes as some Jupyter notebook rendering look really sad without math typesetting.
This is our only usecase at the moment but I can imagine they will be others in the future.

MathJax is a very big library :/

The size of the used MathJax library is around 700 kb prior to gzip compression + 300 kb of web fonts,
feels reasonable to me.

Btw, is it loaded all the time, or just when needed to show a file?

It is only loaded when required of course, currently when rendering a jupyter notebook.

Is it really worth it?

Yes as some Jupyter notebook rendering look really sad without math typesetting.
This is our only usecase at the moment but I can imagine they will be others in the future.

Yes sure, but I meant to self-host it instead of using a CDN

MathJax is a very big library :/

The size of the used MathJax library is around 700 kb prior to gzip compression + 300 kb of web fonts,
feels reasonable to me.

if my memory serves me well, it's also hundreds of MBs in node_modules/

Btw, is it loaded all the time, or just when needed to show a file?

It is only loaded when required of course, currently when rendering a jupyter notebook.

cool

Yes sure, but I meant to self-host it instead of using a CDN

We should self host as much as possible from my point of view.

if my memory serves me well, it's also hundreds of MBs in node_modules/

Hopefully not anymore as the library has been greatly improved in terms of size in its 3.x version.
The mathjax package hosted on npm contains the built library for production use.
The loaded assets are the files I mentioned in my previous comment.

Of course this will increase the swh-web wheel size from around 1 Mb but we are still under the
size of 10 Mb (9.2 Mb for the record).
Compared to the 37 Mb size of swh-graph wheel, this is not excessive.

This revision is now accepted and ready to land.Apr 10 2020, 6:01 PM

Update: Upgrade mathjax to 3.0.5 (version was released after I pushed the diff)

Build is green

Patch application report for D3009 (id=10695)

Rebasing onto 0503cce23f...

Current branch diff-target is up to date.
Changes applied before test
commit 2a3c117fbd9b6ccbfec8e95293795d8bd6e5b421
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Fri Apr 10 15:29:41 2020 +0200

    assets: Upgrade MathJax to 3.x and bundle it with webpack
    
    A new major version of MathJax typesetter has been recently released which
    now enables to properly bundle the library with webpack.
    
    So remove previous CDN use to get MathJax and use a self hosted version from
    now on.
    
    Closes T1680

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/58/ for more details.