'onParserFirstCallInit' is pretty good idea. But it makes math and chem tags disappear in 'Parser extension tags' on [[Special:Version]]
'Lazy initialization of script' is also great idea. It shows unexpected result. I think because 'render' time and 'load' time are not same.
Allow user-defined directory for a local MathJax installation on the
server. The user may set the variable `$wgLocalMathJaxDir` to a
directory relative to server root that contains the MathJax
javascripts. For example, if the directory `MathJax-2.7.1` contains
the `MathJax.js` script, one would add to their `LocalSettings.php`
the following line:
`wgLocalMathJaxDir = '/MathJax-2.7.1';`
and their mediawiki instance should now render math using MathJax
installed on their server rather than on a CDN. **Note** that the
leading '/' is important!
* Init tag functions on ParserFirstCallInit, not extension function
* This remove need for global var $wgParser
* Don't load MathJax on every page load, on BeforePageDisplay
* Load it when <math> or <chem> tags used
* This adds need for global var $wgOut
* Ensure the script is only loaded once by having a static variable
to mark whether or not it has been loaded yet