Snippet

Javascript inclut un fichier js d'un autre

3 réponses de la communauté

var script = document.createElement('script');
script.src = "https://www.examplesite/myscript.js";
document.head.appendChild(script); 
document.writeln("<script type='text/javascript' src='Script1.js'></script>");
document.writeln("<script type='text/javascript' src='Script2.js'></script>");
// jQuery
$.getScript('/path/to/imported/script.js', function()
{
    // script is now loaded and executed.
    // put your dependent JS here.
});