Combine Javascript & CSS

The front end page controller has two methods which let you combine, compress and minify JavaScript and CSS assets. With these methods you can reduce the number of external requests on a page and improve load time by compressing and caching the assets files. PHPR will automatically minify and compress asset files using GZIP.

These methods allow you to include both local and remote files and the following $options are available:

  • reset_cache - force reset the output cache. PHPR will cache combined files on the server. By default it updates the cache as soon as any of the cached files is changed. 
  • skip_cache - do not cache the combined files.
  • src_mode - do not minify the combined files. Retains all comments and formatting.

$this->js_include($assets, $options)

Combines multiple JavaScript files into a single script.

<?= $this->js_include(array(
)) ?>

$this->css_include($assets, $options)

Combines multiple CSS files into a single stylesheet. PHPR will automatically process relative URLs in CSS combined files

<?= $this->css_include(array(
), array(
)) ?>

Minimum Requirements

In order for the PHPR front end JavaScript framework to function correctly, you will need to include three JavaScript files to all your pages -- the jQuery library, the framework core and front-end core library. To include the required libraries, simply call the js_include() method with the aliases jquery, core_jquery, and frontend_core:

)) ?>

PHPR also has a CSS file for styling standard controls used, such as the AJAX loading indicator. You can include it with the core_styles alias in the css_include() method:

<?= $this->css_combine(array(
)) ?>