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
Post a Comment