PHP资源管理框架Assetic简介

2019-11-16,,

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

示例代码如下:

复制代码 代码如下:<?php
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请求。

《PHP资源管理框架Assetic简介.doc》

下载本文的Word格式文档,以方便收藏与打印。