对于一个网站其实很多时候都需要对动态的生成所使用的CSS/JS,其中主要是CSS/JS中所包含的一些URL,当然这些URL信息也可以使用相对路径来实现,但在一些情况下使用相对路径并不能解决这个难题。 按照Yahoo YSlow(http://developer.yahoo.com/yslow/help)的
对于一个网站其实很多时候都需要对动态的生成所使用的CSS/JS,其中主要是CSS/JS中所包含的一些URL,当然这些URL信息也可以使用相对路径来实现,但在一些情况下使用相对路径并不能解决这个难题。
按照Yahoo YSlow(http://developer.yahoo.com/yslow/help) 的建议1,就是必须减少HTTP的请求,当然手动把所有代码合并是一种方法,但这种方法反而会带来两个更糟的问题,把所有CSS/JS都合并到一个文件 中,当然不利于代码的阅读和管理。如果使用jQuery,因为不同的Plugin都是会放在不同的js文件中,和Yahoo YSlow的建议有较大的冲突,当然是用动态语言来合并这些js文件应该是个不错的idea。合并过程中还可以使用jsmin.php来进行js文件的压 缩。
如想使用这个技术可参考以下的几篇说明:
- Automatic merging and versioning of CSS/JS files with PHP
- Adding JSMin to my CSS/JS merging script (这篇写了一般,其实有更好的方法来做)
- GZip files with .htaccess and PHP (这篇是说明如何对输出的PHP内容进行GZip的压缩,因为动态文件无法使用Apache 的 GZIP的库来压缩,所以为了节省传递数据必须在PHP中把输出内容进行压缩)。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version
Visual web development tools
