Last active
October 7, 2016 19:53
-
-
Save Dkra/ac63db5cd56c5fbcae2569660268a50a to your computer and use it in GitHub Desktop.
DOM operation: Synchronous Version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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