如何在另一个 JavaScript 文件中包含一个 JavaScript 文件?

Is there something in JavaScript similar to @import in CSS that allows you to include a JavaScript file inside another JavaScript file?

转载于:https://stackoverflow.com/questions/950087/how-do-i-include-a-javascript-file-in-another-javascript-file

weixin_33734785
weixin_33734785 what is the practical advantage of doing this? either way the code base dependent on javascript file isn't going to load and start working in any case it is not loaded !
3 年多之前 回复
weixin_33690367
weixin_33690367 That wouldn't help to import anything, but it should work as well. If you have a JS file that depends of another JS file, just declare the script tags of the dependency files first, so the later will already have its dependencies loaded. If you have a situation where it isn't a possible approach, the answers here should be helpful.
4 年多之前 回复
weixin_33690367
weixin_33690367 Why not declaring the imported file before the other one that requires it, simply using ordered script tags?
5 年多之前 回复
weixin_33692284
weixin_33692284 I do not want to use an AJAX call.
11 年多之前 回复
weixin_33670713
weixin_33670713 stackoverflow.com/questions/21294/…
11 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐