简体   繁体   English

我如何包含所有js文件,就像我们将所有css文件添加到一个main.css中一样

[英]How can I include all js files like we add all css files in one main.css

We can use all css files as one file for example main.css: 我们可以将所有css文件用作一个文件,例如main.css:

@import url(bootstrap.css);
@import url(bootstrap.min.css);
@import url(bootstrap-theme.css);
@import url(bootstrap-theme.min.css);
@import url(style.css);
@import url(w3.css);

How can we include and use all js files as one main.js and use all javascript files for example 我们如何包含和使用所有js文件作为一个main.js并使用所有javascript文件作为示例

main.js main.js

<script src="http://127.0.0.1:7070/js/aa.js">
<script src="http://127.0.0.1:7070/js/bb.js">
<script src="http://127.0.0.1:7070/js/cc.js">
<script src="http://127.0.0.1:7070/js/dd.js">
<script src="http://127.0.0.1:7070/js/ee.js">

You can't natively include JS files like the import statement in CSS (though it's important to note that the CSS import still downloads multiple files, it's just a convenience for organizing the rules. ) 您不能像CSS中的import语句一样在本地包含JS文件(尽管需要注意的是CSS导入仍会下载多个文件,但这只是组织规则的一种方便。)

Have a look at tools like Webpack, require.js, Grunt, and Gulp. 看一下Webpack,require.js,Grunt和Gulp之类的工具。 All of which do concatenation and minification for you as build steps. 所有这些都在构建步骤中为您进行串联和最小化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用gulp concat for CSS如何将main.css连接到我的所有其他CSS - Using gulp concat for css how do I concat main.css to all of my other css Typo3 - 如何在合并文件中包含所有 CSS 和 JS 文件 - Typo3 - How to include all CSS and JS Files in merged File 加载以main。*。css和main。*。js开头的所有css和Js文件 - Load all css and Js files starting with name main.*.css and main.*.js Nginx:我想http2_push目录中的所有js和css文件怎么办? - Nginx: I want to http2_push all js and css files in a directory how can I do? 如何将我的 Wordpress 网站中的所有 CSS 文件合并为一个? - How can I merge all the CSS files in my Wordpress website into one? 如何在Spring Mvc中使用jsps添加CSS和js文件 - how can I add css and js files with jsps with spring Mvc 我该如何破坏缓存,以便用户获得所有新的静态文件(例如style.CSS,main.js)? - How do I bust the cache so users get all the new static files (eg. style.CSS, main.js)? 我应该将所有 js 文件包含到一个 js 文件中吗? - Should i include all my js files to one js file? WebPack如何将所有css文件放入一个css文件中 - WebPack how to put all css files into one css file 在安装时将所有(* .js)或(* .css)文件批量添加到服务工作者缓存 - Bulk Add All (*.js) or (*.css) files to service worker cache on install
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM