Production checklist
Styles and fonts
- KaTeX: load
katex/dist/katex.min.css.createMorphwaits fordocument.fonts.readybefore measuring. - MathJax: the renderer injects its stylesheet into
document.headon first use. For shadow roots, adoptrenderer.stylesheet().
Server-side rendering
Morphing needs real layout, so it runs in the browser only. Render static formulas on the server, then hand them to texmorph on the client with { adopt: element } (see Chaining steps).
Resizing
Call morph.refresh() when the container's width or the fonts change. The Web Component does this automatically.
Accessibility
- Exactly one formula is exposed to assistive technology at any time: the source until the morph completes, then the target. Ghosts are
aria-hidden. - texmorph does not check
prefers-reduced-motionitself, because it does not own playback. Respect it in your player, for example by renderingt = 1directly. The Web Component does this forplay().
Content Security Policy
texmorph writes styles through the CSSOM and never uses innerHTML or eval, so it works under a strict style-src and script-src. When passing styles to the Web Component under CSP, prefer a constructed CSSStyleSheet over a string.
Security
KaTeX's trust: true is rejected; pass a function that allows specific commands instead. The MathJax renderer refuses the html, require and autoload TeX packages. See SECURITY.md.
Performance
- Prepare costs about one render plus measurement per formula. Prepare the next step while the current one is still on screen if latency matters.
render(t)only writestransform,opacityandcolor; it does not trigger layout.- Each morph adds one absolutely positioned element per symbol while it is alive. Dispose of morphs you no longer need.