Open source works-php write JS and CSS file compression tool-suminify_php_1_5

Source: Internet
Author: User
Tags php write
Objective:

Web site projects need to reference external files to reduce load traffic, and the first time an external resource file is loaded, other pages with the same domain name can read the local cache resource file directly by using the browser cache without having to download the same external resource file for each page if they refer to the same address. External resource files are some third-party plug-ins, some are their own written business function script, project reference to these external files, need to compress the third-party plug-in compression and then reference, and their own business function scripts, and some into the plug-in form, referencing a functional script, you need to reference a number of script files, Therefore, these script files need to be merged into a single compressed file and then referenced, which can reduce the number of HTTP requests and reduce the load traffic of these external resource files.
In order to achieve these goals, the original step is: Create a new. min.xxx file in the target path opens the website that provides the online JS/CSS compression service, copies the source code into the online compression, then copies it, sticks it to the. min.xxx file, and if you need to merge the files, copy the source code of multiple files. Compress and paste to the same. min.xxx file. But with the progress of the project, more and more functions, the need to refer to the file is more and more, each time you change an external source file, it will take a lot of effort to update the. min.xxx files, especially the source files are distributed in different directories, in order to find these directories is also very troublesome. So the idea of doing a small program of automated compression merging, just run this program, can help me to complete these tedious repetitive work.

Brief introduction:
Suminify_php is a single-file green PHP program for compressing or merging JS files or CSS files in a Web site project, and phpinfo.php is as easy to use as a project.
In the development of Web site projects, JS files are often distributed in various directories, such as third-party plug-ins, their own written plugins, etc., will generally be compressed into a number of JavaScript plug-ins into a file for project reference, to reduce the number of HTTP requests.
If the manual operation, each time the plug-in changes, it takes a lot of effort to compress and merge files, with this automation program, you can put the project's external resource files according to the rules of an automated configuration, and then each time the file changes, just run the Suminify program, You can compress or merge files into a specified directory according to the rules, eliminating the need for laborious manual work and increased productivity.

Characteristics:
1, single file green version, no external dependencies, easy to deploy and use
2, support multiple projects quickly switch
3, according to the rules to write a good configuration file, according to the configuration file automatically read the source code from the source path and compression, output to the specified. Min Compressed file
4, the project's rule configuration file can be placed in any path
5. Merging the contents of multiple files in different directories into one file
6, the entire directory in-place batch compression, such as the directory has a number of files, just fill in the directory path, you can automatically traverse the directory files, and in each filename +.min. suffix format to generate the compressed file
7. After compressing the entire directory's resource files, merge them into a. min file of a specified path
8, the entire directory in-place batch compression, automatically ignore. min file, prevent duplicate compression

Use:
1. Copy the suminify_php_1_5 file to any directory in your project (this file is a single-file green version for easy use of ^_^).
2. Modify the configuration to fit the rules you need.
3. Run this file, once the build is successful, you can view and use your results ~

Help:

$config=Array(    //SOUI_V3A Project' soui_v3a ' = ' F:\OpenOpus\SuMinify_PHP_1_5\Example\soui_v3a_config.php ',//soui_v3b Project' Soui_v3b ' =Array(        ' JS ' =Array(            ' In-place-minify ' =Array(//In- place compression JS' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Javascript\superfish\superfish.js ',//generate superfish.min.js files in placeArray(' path ' = ' f:\openopus\suminify_php_1_5\example\resfile\javascript\pages\* ', ' skips ' =Array(' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Javascript\Pages\skip-me1.js ', ' F:\OpenOpus\SuMinify_PHP_1_5\ Example\resfile\javascript\pages\skip-me2.js ')),//The entire directory is compressed in-place, skipping the compression of 2 of these files), ' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Javascript\min\jquery.easyui.min.js ' =Array(                Array(' path ' = ' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Javascript\easyui\jquery.easyui.min.js ', ' minify ' = >false),//no compression, direct merge' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Javascript\easyui\locale\easyui-lang-zh_CN.js ',//Merge after compression), ' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Javascript\min\pages.min.js ' =Array(                Array(' path ' = ' f:\openopus\suminify_php_1_5\example\resfile\javascript\pages\* '),//compress all files in a directory after merging' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Javascript\js-prototype-extension.js ',//Merge after compression' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Plugin\jquery-audioplayer-1.0\jquery-audioPlayer-1.0.js ',//Merge after compression            )        ), ' css ' = =Array(            ' In-place-minify ' =Array(//compress css in place' F:\openopus\suminify_php_1_5\example\resfile\css\pages\* ',//entire Directory in-place compression), ' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Css\jeasyui\Default\easyui.min.css ' =Array(                ' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Css\jeasyui\Default\easyui.css ',//Merge after compressionArray(' path ' = ' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Css\jeasyui\icon.css ', ' replaces ' =Array("' icons/" = "" '. /icons/")),//Replace content after compression, then merge), ' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Css\superfish\superfish.min.css ' =Array(                ' F:\OpenOpus\SuMinify_PHP_1_5\Example\Resfile\Css\superfish\superfish.css ',//In- place compression),        )    ),);

Run:

Home: Http://git.oschina.net/sutroon/SuMinify_PHP_1_5

Source: Https://git.oschina.net/sutroon/SuMinify_PHP_1_5.git

The above introduces the open source works-php write JS and CSS file compression tool-suminify_php_1_5, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

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