Self-hosted MathJax

Self-hosted MathJax

This directory contains a vendored copy of MathJax v3.2.2 (the tex-chtml configuration). It is served from our own origin and loaded by _includes/mathjax-custom.html on any page with use_math: true in its front matter.

Why it’s vendored (not loaded from a CDN)

The site previously loaded MathJax from https://cdn.mathjax.org/.... That CDN was retired in 2017 and now serves only a tiny JS shim that redirects to cdnjs.cloudflare.com. The math therefore depended on two third-party domains plus runtime script injection.

Some corporate networks (VPN / proxy / Zscaler-style TLS interception) block or break those external requests, which made math fail to render — readers on those machines saw raw $...$ LaTeX instead of equations.

Self-hosting removes every external domain from the math path. If a reader can load the blog, they can load the math engine, because it comes from the same origin.

What’s included

To keep the footprint small (~2 MB instead of the full ~23 MB distribution), only the files that tex-chtml.js actually uses are vendored:

  • tex-chtml.js — the combined TeX-input + CommonHTML-output component.
  • output/chtml/ — the CommonHTML fonts (fonts/woff-v2/), loaded at runtime.
  • input/tex/ — TeX extensions that are autoloaded on demand (e.g. \color, \cancel, \require{...}).

The SVG output, MathML bundles, accessibility/speech-rule engine, and UI menu components were intentionally excluded — they are not used by this config.

How to update

MathJax v3 is stable and rarely needs updating. To bump the version:

# 1. Download and extract the desired version's npm tarball
curl -O https://registry.npmjs.org/mathjax/-/mathjax-<VERSION>.tgz
tar -xzf mathjax-<VERSION>.tgz

# 2. Replace the three vendored paths from package/es5/
cp    package/es5/tex-chtml.js   assets/mathjax/
cp -R package/es5/output/chtml   assets/mathjax/output/chtml
cp -R package/es5/input/tex      assets/mathjax/input/tex

# 3. Rebuild and verify a math post renders (see below)

Verifying

bundle exec jekyll build

Then open any use_math: true post (e.g. /Reasoning-Models/) and confirm equations render and the browser console shows no MathJax load errors.