javascript - How can I check if a JS file has been included already? -


i have split javascript in different files. want prevent, javascript files loaded twice. how can that?

here's test see if script has been included based on path js file:

function isscriptalreadyincluded(src){     var scripts = document.getelementsbytagname("script");     for(var = 0; < scripts.length; i++)         if(scripts[i].getattribute('src') == src) return true;     return false; } 

it work scripts not loaded through ajax, though may want modify if have jsonp code running.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -