Difference between revisions of "MediaWiki:Common.js"

From Mechanics
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: →‎add extra time to load math equations on mobile screens: function waitForMathJax($content) { if (typeof MathJax === 'undefined') { setTimeout(function () { waitForMathJax($content); }, 1000); } else { MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]]).execute(); } } mw.hook('wikipage.content').add(waitForMathJax);")
 
Line 4: Line 4:
function waitForMathJax($content) {
function waitForMathJax($content) {
   if (typeof MathJax === 'undefined') {
   if (typeof MathJax === 'undefined') {
     setTimeout(function () { waitForMathJax($content); }, 1000);
     setTimeout(function () { waitForMathJax($content); }, 2000);
   } else {
   } else {
     MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]]).execute();
     MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]]).execute();

Revision as of 10:53, 16 February 2022

/* Any JavaScript here will be loaded for all users on every page load. */

/* add extra time to load math equations on mobile screens */
function waitForMathJax($content) {
  if (typeof MathJax === 'undefined') {
    setTimeout(function () { waitForMathJax($content); }, 2000);
  } else {
    MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]]).execute();
  }
}

mw.hook('wikipage.content').add(waitForMathJax);