assetic是一個(gè)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();
采用這種方式合并資源可以減少瀏覽器對(duì)資源的請(qǐng)求數(shù)、降低資源下載大小、加速站點(diǎn)運(yùn)行速度。也消除了大量不必要的http請(qǐng)求。
更多信息請(qǐng)查看IT技術(shù)專欄