JavaScript: document.createNode or plain html?

Is it better to use

document.createNode();

or plain text for example

var foo = '<div> bar </div>';

create HTML markup using JavaScript?

+5
source share
3 answers

In this particular case there is no “best”, it will come down to what is most easily supported. and programmer preference.

In some browsers, using the DOM to create elements and nodes, in terms of performance, is faster than others. Some user agents process strings faster, for example, by setting a property innerHTML.

DOM, mootools, . jQuery .

: http://jsperf.com/string-vs-createelement/3, : http://www.quirksmode.org/dom/innerhtml_old.html http://karma.nucleuscms.org/item/101

+2

DOM node. , jQuery, DOM.

var foo = $('<div> bar </div>');
+2

DOM, , , , , , .

, , DOM .

, , CSS, , JS, .

html IE (, , IE innerHtml ), , , html, html, .

, DOM node.

0
source

All Articles