amp-mathml is painfully slow. Benchmarking amp-mathml vs. KaTeX
Describe the new feature or change to an existing feature you'd like to see
The current version of amp-mathml seems to be based on MathJax. This is a huge bottleneck for pages with lots of math. An alternative version based on KaTeX might fix this.
Describe alternatives you've considered
The current implementation does work, but it doesn't deliver on the fast load times AMP intends to have.
Additional context
I cannot promise intend-to-implement I2I any time soon.
Benchmarks below.
The Benchmark
This benchmark is based on a summary of "Mirror Descent for Metric Learning: A Unified Approach" that includes 88 math blocks, mixed between inline blocks and equations.
Two versions of this web page were created:
- Based on
amp-mathml - Based on KaTeX
Reproducing
See this gist: https://gist.github.com/hayesall/33ba7aed8ebfbf0dba761cb7ba501342
git clone https://gist.github.com/hayesall/33ba7aed8ebfbf0dba761cb7ba501342 hayesall-amp-demo
cd hayesall-amp-demo
python -m http.server # Start an HTTP server with Python 3| AMP Complient? | Method | URL |
|---|---|---|
| No | KaTeX | http://0.0.0.0:8000/katex.html |
| Yes | amp-mathml |
http://0.0.0.0:8000/amp-mathml.html#development=1 |
Preview of part of the benchmark page:

Benchmark 1: amp-mathml
- Gist:
amp-mathml.html - githack: Live Demo Page
All equations were rendered after around 22,000 ms:

Benchmark 2: KaTeX
- Gist:
katex.html - githack: Live Demo Page
There is some delay in the beginning between when I refreshed the page, but the rendering took place between 1000 ms and 1200 ms, or around 200 ms.

Source: ampproject/amphtml