简体   繁体   中英

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:

@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

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. )

Have a look at tools like Webpack, require.js, Grunt, and Gulp. All of which do concatenation and minification for you as build steps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM