should all javascript go into a separate js file

后端 未结 6 1293
别跟我提以往
别跟我提以往 2020-12-15 12:26

What is the criteria if certain jquery or regular javascript should go inline or in a separate js file?

6条回答
  •  借酒劲吻你
    2020-12-15 12:53

    Personally, I think it's a personal choice, and depends on the situation. If it's a just a couple lines of Javascript, I don't bother to make a separate file (and another HTTP request). However, if it is more, with functions and more than trivial impact, I put it in a external file.

    Also, if the code will be used on more than one page, it should always go in a separate file, even if it is just a couple lines.

提交回复
热议问题