asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
322 stars 97 forks source link

Upgrade to MathJax 3.x #725

Open ggrossetie opened 1 year ago

ggrossetie commented 1 year ago

I think we should upgrade MathJax to 3.x

yne commented 2 months ago

Hi @ggrossetie , Can we take this opportunity to improve the VSIX bundling ? The current VSIX is 30.8MiB mainly because of MathJax (and goes down to 7.5MiB without it) Since we can't include all the plugins in the world (example: mermaid) why not make them modular ?

We also include a lot of unused content : dist/browser, dist/src/test, *.map, node_modules/@asciidoc/core/dist/{browser,graal}, fontawesome (otf, ttf, woff,woff2, svg) which, once removed gives us ad 4.9MiB VSIX

The reason behind this request is that my colleagues use asciidoc on remote machines. Those machines traverse many NAT/proxies/corporate firewalls, and they extranet download are painfully slow (but not blocked unlike https://github.com/microsoft/vscode/issues/195911). This makes the update (and even the installation) of a 30MiB VSIX almost impossible to justify to my asciidoc creators.

4.9MiB VSIX: asciidoctor.asciidoctor-vscode-3.2.3.zip (rename .zip as .vsix)

ggrossetie commented 2 months ago

We also include a lot of unused content : dist/browser, dist/src/test, *.map, node_modules/@asciidoc/core/dist/{browser,graal}, fontawesome (otf, ttf, woff,woff2, svg) which, once removed gives us ad 4.9MiB VSIX

Feel free to submit a pull request to improve the bundling. I did some work in the past with esbuild: https://github.com/asciidoctor/asciidoctor-vscode/pull/506

The current VSIX is 30.8MiB mainly because of MathJax (and goes down to 7.5MiB without it) Since we can't include all the plugins in the world (example: mermaid) why not make them modular ?

By default, Asciidoctor does not use all the features available in MathJax so we could create a trimmed down version of MathJax. That's what I did in the browser extension for similar reasons: https://github.com/asciidoctor/asciidoctor-browser-extension/tree/main/app/vendor/MathJax-3.0.1

If we don't include it, it means that we need to rely on a CDN (and, as a result, it won't work offline)/ Currently, we don't have an adapter facility to integrate MathJax as a plugin, see: https://github.com/asciidoctor/asciidoctor/issues/4522

yne commented 2 months ago

I thought mathjax really was 23MB, in which case, saving 3MB in better bundling would not make a big difference. I'll try to see what can be stripped from mathjax and send a PR 👍