Detailed description of how to merge multiple js and css files

Source: Internet
Author: User
Tags website performance

In the development of Web projects, js and css files will become larger and larger with the development of projects, which brings some performance problems, such as js introduced by pages, the more css, the higher the number of http requests. A good solution to this problem is to merge js and css files.
The following describes a simple method. The following describes how to merge js files.

(1) G. js File Copy codeThe Code is as follows :~ Function (){
Window. G = {};
G. Method = {
Add: function () {alert (111 );}
, Sub: function () {alert ("subtraction ");}
};
}();

(2) T. js File Copy codeThe Code is as follows: var T = (function (){
Return {
T1: function () {alert ("t1 method! ")}
, T2: function () {alert ("t2 method! ")}
, Sum: function (obj) {return obj. x + obj. y ;}
};
}());

A simple js file is listed above. Next we need to write a batch file to merge the above files.
(3) Merge js and css files in batches. Assume the file name is named debug. bat. Copy codeThe Code is as follows: copy G. js + T. js GT_bin.js/B

Description:
(1) enter the js file to be merged, save the debug. bat file, and run debug. bat.
(2) This is just a line of code. It is very simple. GT_bin.js is the name of the merged file./B is a fixed parameter. After the file is merged, only GT_bin.js can be referenced on the page, which reduces the number of js file references, reduces the number of http requests, and improves the website performance.
(3) The same is true for merging css files.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.