我正在开发一个包含大量数学表达式的网站。我将 MathJax 与 React 结合使用(使用“react-mathjax-preview”),但我注意到渲染数学方程很慢,并且在刷新页面时可以注意到。我与使用 MathJax(例如 Mathematics Stack Exchange)的网站进行了比较,发现方程的渲染速度更快(即使页面包含大量数学表达式)。那么为什么我的数学运算速度变慢了呢?以及如何让它像Mathematics Stack Exchange一样快速?
注意:我尝试使用KaTex和react,它比MathJax更快,但是分数和根的定位以及文本样式存在一些问题。所以我又回到了 MathJax,因为它还提供了更多的 Latex 函数,并且比 KaTex 使用得更多。
注意:当数学表达式包含在表中时,问题似乎更严重,因为它们是写在单独的<MathJax />组件中的。
例如,这段代码渲染得很慢,但它只包含 9 个数学表达式。(我工作的一些页面包含超过 50 个独立的数学表达式(即使使用“对齐”环境等环境)。
<div>
<table className="table-style-a2">
<thead>
<tr>
<th>Radical in the integral</th>
<th>Trigonometric substitution</th>
<th>Hyperbolic substitution</th>
</tr>
</thead>
<tbody>
<tr>
<td><MathJax math={String.raw`$\sqrt{a^2-x^2}$`} /></td>
<td><MathJax math={String.raw`$x = a \sin (\theta)$`} /></td>
<td><MathJax math={String.raw`$x = a \tanh (\phi)$`} /></td>
</tr>
<tr>
<td><MathJax math={String.raw`$\sqrt{a^2+x^2}$`} /></td>
<td><MathJax math={String.raw`$x = a \tan (\theta)$`} /></td>
<td><MathJax math={String.raw`$x = a \sinh …Run Code Online (Sandbox Code Playgroud)