Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
MathJax layout adjustments still going on when subsequent scripts are executed - How to run them after the rendering is really fixed?

My Android app loads an XHTML file into a WebView.

When the page is finished loading some scripts are called.

The HTML page contains MathML or other math code that is to be precessed by an injected MathJax script.

String scriptText=
                    "MathJax.Hub.Config({ "
                    + "showMathMenu: false, "
                    + "jax: ['input/TeX','output/HTML-CSS'], "
                    + "showProcessingMessages: false, "
                    + "messageStyle: 'none', "
                    + "extensions: ['tex2jax.js'], "
                    + "TeX: { extensions: ['AMSmath.js','AMSsymbols.js',"
                    + "'noErrors.js','noUndefined.js'] } "
                    + "});";

            
String js_command = "var newScript = document.createElement(\"script\");"
+"newScript.setAttribute('type','text/x-mathjax-config');"
+"var inlineScript = document.createTextNode(\""+scriptText+"\");"
+"newScript.appendChild(inlineScript);"
+"document.body.appendChild(newScript);"

+"newScript = document.createElement(\"script\");"
+"newScript.setAttribute('type','text/javascript');"
+"newScript.setAttribute('src','file:///android_asset/MathJax/es5/tex-mml-svg.js');"
+"document.body.appendChild(newScript);";

The injection of MathJax code is successful and the code is execute, rendering the math symbols correctly.

Also refer to My other question about the MathJax script injection

The fact is that other scripts have to be executed and they have to run after the MathJax rendering.

The MathJax script has neither the async or the defer attribute because I need that the subsequent scripts are executed after the real rendering of the math symbols. But I tried adding the defer condition and nothing changes.

Indeed I noticed that when the script has finished running, so the next JavaScript is going to be executed, the rendering still goes on for some elements, some of which can slightly change size, for example. This leads to some issues in my app, that is heavily based on exact positioning.

I browsed the JavaScript file that is used in my app as MathJax code and I saw that it is all on one line, and nothing can be understood because it is full of boiler-plate instructions.

Also I did not find the corresponding source code in a plain form in the github repository, although the folder is there.

My question: I would like to know how to execute the MathJax operations in a real sync fashion, so that the subsequent JavaScript code is executed when all the real rendering is fixed as to positions and dimensions.

I am also eager to edit the MathJax script inserting calls to other scripts inside a specific function so to be sure they are executed at the end.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!