Search code examples
google-chrome-extensionfirefox-addon

window.MathJax is undefined in Firefox, works in Chrome extension


I'm trying to write a Chrome/Firefox extension in inject MathJax 3.0.1 into arbitrary web pages, Green Pi. It's working well for Chrome, but I'm having trouble with Firefox.

The content_script.js is

MathJax = {  
  chtml: {  
    fontURL: chrome.runtime.getURL("fonts"),  
  },  
};  
require("mathjax-full/components/src/tex-chtml/tex-chtml.js"); 

// This paints pages green
// require("green.js");
// // cat green.js == document.body.style.backgroundColor = "green";

(It's getting a little more involved when the user opts in/out of certain pages, but this isn't relevant here.)

Now, as noted in the code, the above works fine in Chrome, but fails in Firefox with the MathJax error

MathJax(?): window.MathJax is undefined

I don't see any other warning or error. Any hint on what might be going wrong here?


Solution

  • This turned out to be a MathJax bug after all, cf. https://github.com/mathjax/MathJax/issues/2399.