Skip to content

Instantly share code, notes, and snippets.

@Dkra
Last active October 7, 2016 19:53
Show Gist options
  • Save Dkra/ac63db5cd56c5fbcae2569660268a50a to your computer and use it in GitHub Desktop.
Save Dkra/ac63db5cd56c5fbcae2569660268a50a to your computer and use it in GitHub Desktop.
DOM operation: Synchronous Version
// Just for check if page responsable or clog already by clicking page
const el = document.getElementsByTagName('html')[0];
el.addEventListener('click', function(){
console.log('html click handler processed');
})
console.log('START RUN THE CODE');
var t0 = performance.now();
// Blocking version
for (let i = 0; i < 10000; i++) {
$('body').append('<span>haha</span>')
}
var t1 = performance.now();
/*
* Checking duration between t0 line to t1 line
*/
console.log('code block duration:', (t1-t0) , " milliseconds.");
// Check length of span is equal in different approach
console.log('number of span', $('body span').length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment