As i have been testing my site, i have noticed that .innerHTML is far quicker than jquery's append methods. This is depricated tho and support may dwindle and die in future browsers. That said the bgcolor attribute still works and i remember being told that was being depricated about a decade ago. Dont append scripts with the html fragment either as they need eval'ing (Jquery appears to do this automatically leading to slow times whereas with innerHTML you have to do it manually if needed). Eval is dead slow dont use it if possible. Again as previously mentioned joining an array is more efficeint than string concatenation. Use variables to point to dom nodes (ie. var this = document.getElementById("YourDomNode") then work with 'this' where needed instead of repeating the document.getElementById statement). Declaring variables outside of a function allows them to be accessible from any function. Please note this is client side script so the variable value is a unique reference for each user. Doing that highly repeated strings can reduce file sizes depending what your doing. If you absolutely have to load in your javascript inline as part of your html fragments try this:
Call this section after appending to the dom with innerHTML
var f = function() {runScripts(document.getElementById('newDOM_Section'));};
setTimeout(f,1);
**
Stick the following in your main .js file
var stringScript
var f
function runScripts(element) {
var scripts = element.getElementsByTagName("script");
var intScriptsCount = scripts.length
for (var i = 0; i < intScriptsCount; i++) {
stringScript = scripts[i].text
setTimeout(stringScript, 1);
}
}
The above code will make the dom changes visible before all the scripts are eval'd. This isnt multi-threading tho so be careful of its use. Far better to use attributes for event handlers (onclick, onchange etc.)
Finally before manipulating an element in the dom set the style to display:none, manipulate it then set the style back to display:inline (inline is default for some common elements) or wahtever it was previously.
This is just a quick mental dump of some tactics ive used so any input / derision of bad practice is welcome.