loading js files dynamically via another js file?

前端 未结 5 1875
慢半拍i
慢半拍i 2020-12-09 06:30

is there anyway to load other JS files from within a single JS file. I would like to point my individual pages \"ITS\" js file and that js file would load jquery, other js f

5条回答
  •  佛祖请我去吃肉
    2020-12-09 07:04

    You can take a look at dynamic script loading. Here's an excerpt from the article:

    var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'helper.js';
    head.appendChild(script);
    

提交回复
热议问题