[Jifty-commit] r4117 - jifty/trunk/share/web/static/js
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Sep 15 09:51:12 EDT 2007
Author: clkao
Date: Sat Sep 15 09:51:12 2007
New Revision: 4117
Modified:
jifty/trunk/share/web/static/js/jifty.js
Log:
When replacing a region, use the technique described in
http://blog.stevenlevithan.com/archives/faster-than-innerhtml
to improve performance.
Modified: jifty/trunk/share/web/static/js/jifty.js
==============================================================================
--- jifty/trunk/share/web/static/js/jifty.js (original)
+++ jifty/trunk/share/web/static/js/jifty.js Sat Sep 15 09:51:12 2007
@@ -826,6 +826,20 @@
}
};
+// Faster than innerHTML
+function replaceHtml(el, html) {
+ var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
+ /*@cc_on // Pure innerHTML is slightly faster in IE
+ oldEl.innerHTML = html;
+ return oldEl;
+ @*/
+ var newEl = oldEl.cloneNode(false);
+ newEl.innerHTML = html;
+ oldEl.parentNode.replaceChild(newEl, oldEl);
+ /* Since we just removed the old element from the DOM, return a reference
+ to the new element, which can be used to restore variable references. */
+ return newEl;
+};
// Keep track of the state variables.
var current_args = $H();
@@ -962,7 +976,7 @@
var insertion = eval('Insertion.'+f['mode']);
new insertion(element, textContent.stripScripts());
} else {
- Element.update(element, textContent.stripScripts());
+ replaceHtml(element, textContent.stripScripts());
}
// We need to give the browser some "settle" time before
// we eval scripts in the body
More information about the Jifty-commit
mailing list