Can you use multiple .JS files when developing a complex Javascript application?

前端 未结 4 1532
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-01 02:03

Coming from a C# background where every class is (best practices) stored in its own individual file, it makes development quite clean. I\'ve never written anything complex in Ja

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 02:44

    Of course you can use more than one javascript file. How else would libraries like jQuery or Knockout function?

    One thing to keep in mind, though, is that one of the things you want to do to keep your pages feeling snappy is to reduce the total number of http requests per page load. Adding a bunch of javascript files that are loaded separately causes an additonal request for each extra file. Therefore, you might want to experiment with a system for your build that stitches your javascript files together into a single item that you can use at deployment. There are a number of solutions out there that will do this for you in an automated way.

提交回复
热议问题