Skip to content

Instantly share code, notes, and snippets.

View ja0nz's full-sized avatar

@hey@ja.nz ja0nz

View GitHub Profile
@oliverfernandez
oliverfernandez / gist:5619180
Created May 21, 2013 11:31
The operation consists to append 12 nodes to an existing parent node with 1000 children Three ways to do it: 1. Use parentNode.innerHTML += 2. User parentNode.innerHTML = 3. Use a parentNode.appendChild inside a loop. The method with the best performance is the last one. The last method doesn't need to read the current DOM or parse it.
var mainNodeInner = document.createElement('div'),
mainNodeInnerPlus = document.createElement('div'),
mainNodeAppend = document.createElement('div'),
sampleHTML = '<div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>',
testHTML = '',
numSamples = 1000,
before = null,
after = null;
//SET UP