fix: conditionally load MathJax (#37360)
* fix: Removed MathJax CDN from header and set it up to download whenever a user goes to a Rosetta Code challenge * Reworked slightly so that MathJax CDN script is only rendered once * Simplified further * Resolved conflicts and updated MathJax fallback to work like the one on donate.js * Escaped backticks in scriptLoaders.js * refactor: remove reliance on state
This commit is contained in:
committed by
Ahmad Abdolsaheb
parent
f6add96fd6
commit
77b27d79f6
@@ -22,6 +22,7 @@ const mathJaxCdn = {
|
||||
address:
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/mathjax/' +
|
||||
'2.7.4/MathJax.js?config=TeX-AMS_HTML',
|
||||
id: 'mathjax',
|
||||
key: 'mathjax',
|
||||
type: 'text/javascript'
|
||||
};
|
||||
@@ -63,10 +64,11 @@ export const onRenderBody = ({
|
||||
/>
|
||||
];
|
||||
|
||||
if (pathname.includes('/learn/coding-interview-prep/rosetta-code/')) {
|
||||
if (pathname.includes('/learn/coding-interview-prep/rosetta-code')) {
|
||||
scripts.push(
|
||||
<script
|
||||
async={true}
|
||||
async={false}
|
||||
id={mathJaxCdn.id}
|
||||
key={mathJaxCdn.key}
|
||||
src={mathJaxCdn.address}
|
||||
type={mathJaxCdn.type}
|
||||
@@ -81,6 +83,7 @@ export const onRenderBody = ({
|
||||
id={stripeScript.id}
|
||||
key={stripeScript.key}
|
||||
src={stripeScript.address}
|
||||
type={stripeScript.type}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user