SilverCart\View\Requirements_Backend::combineFiles
------------------------------------------------------------------------- -------------------------------------------------------------------------
<b>BUGFIX:</b><br/> Uses <i>ModuleResourceLoader::singleton()->resolvePath($file)</i> to fix a file path issue with combined files in live mode. ------------------------------------------------------------------------- ------------------------------------------------------------------------- Concatenate several css or javascript files into a single dynamically generated file. This increases performance by fewer HTTP requests. The combined file is regenerated based on every file modification time. Optionally a rebuild can be triggered by appending ?flush=1 to the URL. All combined files will have a comment on the start of each concatenated file denoting their original position. CAUTION: You're responsible for ensuring that the load order for combined files is retained - otherwise combining JavaScript files can lead to functional errors in the JavaScript logic, and combining CSS can lead to incorrect inheritance. You can also only include each file once across all includes and combinations in a single page load. CAUTION: Combining CSS Files discards any "media" information. Example for combined JavaScript: <code> Requirements::combine_files( 'foobar.js', array( 'mysite/javascript/foo.js', 'mysite/javascript/bar.js', ), array( 'async' => true, 'defer' => true, ) ); </code> Example for combined CSS: <code> Requirements::combine_files( 'foobar.css', array( 'mysite/javascript/foo.css', 'mysite/javascript/bar.css', ), array( 'media' => 'print', ) ); </code>
- Author: Sebastian Diel <sdiel@pixeltricks.de>
Signature
public function combineFiles(string
$combinedFileName,
array
$files,
[array
$options = ] )
Parameters
$combinedFileName
— string- Filename of the combined file relative to docroot
$files
— array- Array of filenames relative to docroot
$options
— array- Array of options for combining files. Available options are:
- 'media' : If including CSS Files, you can specify a media type
- 'async' : If including JavaScript Files, boolean value to set async attribute to script tag
- 'defer' : If including JavaScript Files, boolean value to set defer attribute to script tag
Returns
- void