JSFiddle - React, Tailwind, and code Playground
by gutek
HTML
<div id="test"></div>
JavaScript
// similar to SPList.Items in foreach(SPListItem item in SPList.Items);
var org = document.getElementsByTagName;
document.getElementsByTagName = function(tag) {
console.log('getting tags:', tag);
return org.call(document, tag);
}
function insertDivs() {
var el, i, toInsert;
toInsert = document.getElementById('test');
for(i = 0; i < 100; i += 1) {
el = document.createElement('div');
toInsert.appendChild(el);
}
}
insertDivs();
function wrong () {
var i;
for(i = 0; i < document.getElementsByTagName('div').length; i += 1) {
}
}
function test (name, method) {
console.time(name);
console.group(name);
method();
console.groupEnd(name);
console.timeEnd(name);
}
test('wrong acess', wrong);
test('ok acess', ok);
function ok () {
var i, l = document.getElementsByTagName('div').length;
for(i = 0; i < l; i += 1) {
}
}