Introduction to PHP Resource Management Framework Assetic

  • 2021-06-29 10:31:28
  • OfStack

Assetic is an PHP resource management framework for consolidating and compressing CSS/JS resources.

The sample code is as follows:

<?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();


Consolidating resources in this way can reduce the number of browser requests for resources, reduce the size of resource downloads, and speed up the site.A large number of unnecessary HTTP requests were also eliminated.

Related articles: