Skip to content

Instantly share code, notes, and snippets.

@connordavison
Created December 31, 2015 14:06
Show Gist options
  • Save connordavison/078257e8b69ea6cf75cc to your computer and use it in GitHub Desktop.
Save connordavison/078257e8b69ea6cf75cc to your computer and use it in GitHub Desktop.
Inject MathJax into the page (protocol agnostic).
(function () {
var cdn, config;
if (typeof MathJax !== "undefined" && MathJax !== null) {
return;
}
config = document.createElement('script');
config.setAttribute('type', 'text/x-mathjax-config');
config.innerHTML = "MathJax.Hub.Config({\n tex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']]}\n});";
cdn = document.createElement('script');
cdn.setAttribute('type', 'text/javascript');
cdn.setAttribute(
'src',
window.location.protocol
+ '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
);
document.head.appendChild(config);
return document.head.appendChild(cdn);
})();
@AugustKarlstedt
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment