PHP资源管理框架Assetic简介
示例代码如下:
<?php useAssetic\Asset\AssetCollection; useAssetic\Asset\FileAsset; useAssetic\Asset\GlobAsset; $js=newAssetCollection(array( newGlobAsset('/path/to/js/*'), newFileAsset('/path/to/another.js'), )); //thecodeismergedwhentheassetisdumped echo$js->dump();
采用这种方式合并资源可以减少浏览器对资源的请求数、降低资源下载大小、加速站点运行速度。也消除了大量不必要的HTTP请求。