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();
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简介的全部内容,更多相关PHP资源管理框架Assetic简介内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复