Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

240
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda