Nel tutorial di oggi imparerete come creare una funzione che include files javascript.
La funzione prende in ingresso due parametri, il primo indica il file da includere e il secondo (opzionale) indica la cache.
function include_js(way, cache) { var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); var time = ''; script.type = 'text/javascript'; script.src = way; // Returns javascript without cache by default // ! forces to return a boolean value if(!cache) { time = '?_=' + new Date().getTime(); } head.appendChild(script + time); }



Leave Your Response