Should I copy all my JavaScript sources into one single file?

前端 未结 3 2003
星月不相逢
星月不相逢 2020-12-16 03:22

In a current web project, I\'m using several jQuery plugins and initializing them just before the closing body tag. My question is, from a loading time/performance standpoin

3条回答
  •  天涯浪人
    2020-12-16 03:59

    Any significant quantity of javascript code is better off in a common externalized javascript file because it can be cached more efficiently between all your pages.

    A few lines of code inline in the page before the closing body tag to call some initialization code in an externalized javascript file is perfectly fine and doesn't slow anything down if that's the best way to trigger the initialization.

提交回复
热议问题