Home  >  Article  >  php教程  >  PHP资源管理框架Assetic简介

PHP资源管理框架Assetic简介

WBOY
WBOYOriginal
2016-06-13 09:33:461313browse

Assetic是一个PHP的资源管理框架,用于合并和压缩 CSS/JS 资源。

示例代码如下:

复制代码 代码如下:

use Assetic\Asset\AssetCollection;
use Assetic\Asset\FileAsset;
use Assetic\Asset\GlobAsset;
$js = new AssetCollection(array(
new GlobAsset('/path/to/js/*'),
new FileAsset('/path/to/another.js'),
));
// the code is merged when the asset is dumped
echo $js->dump();



采用这种方式合并资源可以减少浏览器对资源的请求数、降低资源下载大小、加速站点运行速度。也消除了大量不必要的HTTP请求。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn