html - Tie into javascript load event for img tags -


i following tutorial ( https://codelabs.developers.google.com/codelabs/performance-analytics ).

the gist of happening on img load timing mark logged, don't want add onload img tags our entire website. ruled out jquery because measuring performance , not want wait jquery library load because interfere timing measurements. therefore prefer use javascript. pretty after functionality of jquery script.

$('img').load(alert('performance marking event, img loaded')); 

this allow me leave img tags alone , insert script should relatively not affect timing on when img tags loaded.

devin

just record, method went following example in: javascript callback knowing when image loaded

devin

var imgs = document.getelementsbytagname('img'); for(i = 0; i< imgs.length; i++) {     attachmyloadevent(imgs[i]); }  function attachmyloadevent(img) {     img.onload = function(){console.log('img loaded: ' + img.src);}; } 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo