Namespaces
Variants
Actions

MediaWiki:Gadget-mathjax.js

From cppreference.com

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences
// adapted from https://ja.wikisource.org/wiki/MediaWiki:Gadget-mathjax.js
// originally https://gist.github.com/pkra/794a1d9a35ae2428eaff
 
var mathTags = $('.mjax');
if (mathTags.length > 0){ //only do something when there's math on the page
  window.MathJax = { //hook into MathJax's configuration
    AuthorInit: function () {
      MathJax.Hub.Register.StartupHook("End",function () { //when MathJax is done...
        MathJax.Hub.Queue(
            function(){
             mathTags.show(); // .. make the span around the mathy part visible
             $('.mjax-fallback').hide(); //hide fallback
            }
        );
      });
    }
  };
  mw.loader.load('https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_CHTML');//load MathJax with a suitable combined config file
}