console.time("for loop");
for(var i=0; i < 100; i++){
console.log("i is: " + i);
}
console.timeEnd("for loop");
Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts
Wednesday, June 8, 2016
Measure performance of a given JavaScript code
Sunday, March 6, 2016
Tuesday, December 2, 2014
DOM compatibility & fallbacks
DOM compatibility is somewhat a headache for front-end developers when it comes to creating cross-browser support webapps.
I'm writing this small note to self ;) , on a fall-back hack which we can use to overcome this headache.
I'm taking innerText & textContent properties to explain this further,
This image[Screen-shot from 1] depicts browser support for innerText & textContent properties.
In order to support this we can use something like following,
[1] http://www.quirksmode.org/dom/html/
I'm writing this small note to self ;) , on a fall-back hack which we can use to overcome this headache.
I'm taking innerText & textContent properties to explain this further,
This image[Screen-shot from 1] depicts browser support for innerText & textContent properties.
In order to support this we can use something like following,
//create div element
var div = document.createElement('div');
//check textContent supportSo with this we don't need to worry about setting content to our div.
if (div.textContent) {
div.textContent = "textContent support exists.";
// go for the fall-back
} else if (div.innerText) {
div.innerText = "No textContent support.";
}
[1] http://www.quirksmode.org/dom/html/
Subscribe to:
Posts (Atom)
