From 77b27d79f6f3c318d7dc6384e698b53589110aaa Mon Sep 17 00:00:00 2001 From: Kristofer Koishigawa Date: Wed, 30 Oct 2019 21:46:39 +0900 Subject: [PATCH] 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 --- client/gatsby-ssr.js | 7 +++-- client/src/components/layouts/Default.js | 1 + .../Challenges/components/Side-Panel.js | 10 +++++-- client/src/utils/scriptLoaders.js | 27 +++++++++++++++++-- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/client/gatsby-ssr.js b/client/gatsby-ssr.js index 9e468bc0f8..9952bb1296 100644 --- a/client/gatsby-ssr.js +++ b/client/gatsby-ssr.js @@ -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(