reference multiple js files in a single line in a html file

前端 未结 6 2070
时光说笑
时光说笑 2021-01-19 07:04

Is there an easy way to reference all js files in an HTML file rather than referencing it one by one?

Instead of this -



        
6条回答
  •  抹茶落季
    2021-01-19 07:34

    Is there an easy way to reference all js files in an HTML file rather than referencing it one by one?

    For some value of "easy". There is nothing built in to browsers that will do it though.

    Or is there a tool out there that copies the contents of these files into one file and reference that one file instead?

    There are many. cat is the simplest one.

    Call it from your usual build tool.

    You can use something like require.js to combine them at runtime during development, and call r.js via Node from your build tool for packaging for your staging and live environments.

提交回复
热议问题