"Include" one javascript file to another one

This question already has an answer here:

  • How do I include a JavaScript file in another JavaScript file? 50 answers

  • JavaScript executes globally. Adding both scripts on the page makes them available to each other as if they were in one file.

    <script src="1.js"></script>
    <script src="2.js"></script>
    

    However, you should note that JavaScript is parsed "linearly" and thus, "first parsed, first served". If the first script needs something in the second script, but the second script hasn't been parsed yet, it will result in an error.

    If that happens, you should rethink your script structure.

    链接地址: http://www.djcxy.com/p/7332.html

    上一篇: 如何注入jquery到任何网页

    下一篇: “包含”一个JavaScript文件到另一个