During the development process, sometimes the page cannot be updated in time due to caching problems. Sometimes the page introduces unnecessary style script files. Sometimes the performance of the page is slow due to too many files and too large bytes. In order to solve these problems, I personally A tentative solution was envisioned.
The solution is as follows:
describe | Remark | |
resource level |
Resource level of the page: | |
Optimization plan |
Optimization mainly focuses on the following aspects: | Other optimizations are based on development skills and depend on the level of expertise |
File output solution | Based on resource levels and optimization plans, the following four plans are formulated: 1. Directly quote a single file and introduce it in sequence (<link/>, <script/>) 2. Based on 1, perform single file compression 3. Merge into a new single file according to resource level 4. Based on 3, compress the merged files | Thoughts Option 3: How to determine the number of merged files? |
caching problem | Use timestamp suffix | |
f2econfig_json | Configuration file: var f2eJson={ "Update":"20091015",//Update cache according to timestamp "Compress":"1",//File output scheme (1, 2, 3, 4) "Common":[//Public style for the entire site "common/global.css" ], "Module":{ //Module and style "Module 1":["product,.css"] }, "Page":{//Styles owned by each page "index.php":["","sys/index.css"], //The first element stores the module reference name, if not, leave it blank. "search.php":["Module 1","product/search.css"] //Reference multiple modules, separated by ",", for example: module 1, module 2 } } |
|
f2engine.php | 1. Read the json configuration file and convert it into a php array 2. Find the style resources owned by the page based on the resource parameters of each page. 3. Process according to the file output plan 4. Output on the page |
|
example |
For example, the style reference of the search.php page |
Code is under development. Welcome everyone to discuss and give advice.
Original text : http://www.cnblogs.com/nebel/archive/2009/08/03/f2engine_css_js.html