From 19afe782fd435d3ec200aff8fa86d2fba61a42ed Mon Sep 17 00:00:00 2001 From: Beni Cherniavsky-Paskin Date: Thu, 4 Jun 2015 18:00:16 +0300 Subject: [PATCH] Random discovery: make intial math rendering twice faster :-) On a math-heavy 100K doc, speeds up "All math rendered" from 38s to 18s! #68, https://github.com/cben/CodeMirror-MathJax/issues/14 I was doing early hookMath() and postponing renderAllMath() on the theory "Queuing this allows text to appear before math." But doing hookMath() before firepad load already renders all math, and renderAllMath() does all the work again because there is no caching (https://github.com/cben/CodeMirror-MathJax/issues/15). --- mathdown.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mathdown.js b/mathdown.js index 5ab0e1f..8aa6d74 100644 --- a/mathdown.js +++ b/mathdown.js @@ -182,8 +182,6 @@ function setupEditor(editor) { updateTitle(); } }); - - CodeMirror.hookMath(editor, MathJax); } // Firepad @@ -219,6 +217,7 @@ function setupFirepad(editor, firepad) { // Queuing this allows text to appear before math. MathJax.Hub.Queue(function() { + CodeMirror.hookMath(editor, MathJax); editor.renderAllMath(); }); });