How can I split a javascript application into multiple files?

后端 未结 5 1983
心在旅途
心在旅途 2020-12-04 11:19

I created a javascript application with all of the code in one file. The application has grown quite a bit and I think it\'s time to split it up into multiple files, but I\'

5条回答
  •  孤街浪徒
    2020-12-04 11:40

    Give require.js a shot. http://requirejs.org/

    Example:

    require(["dir/file"], function() {
        // Called when file.js loads
    });
    

提交回复
热议问题