Description | manuals and libraries |
Kernel::System::Loader - CSS/JavaScript loader backend
All valid functions.
create an object
my $LoaderObject = $Kernel::OM->Get('Kernel::System::Loader');
takes a list of files and returns a filename in the target directory which holds the minified and concatenated content of the files. Uses caching internally.
my $TargetFilename = $LoaderObject->MinifyFiles(
List => [ # optional, minify list of files
$Filename,
$Filename2,
],
Checksum => '...' # optional, pass a checksum for the minified file
Content => '...' # optional, pass direct (already minified) content instead of a file list
Type => 'CSS', # CSS | JavaScript
TargetDirectory => $TargetDirectory,
TargetFilenamePrefix => 'CommonCSS', # optional, prefix for the target filename
);
returns the minified contents of a given CSS or JavaScript file. Uses caching internally.
my $MinifiedCSS = $LoaderObject->GetMinifiedFile(
Location => $Filename,
Type => 'CSS', # CSS | JavaScript
);
Warning: this function may cause a die() if there are errors in the file, protect against that with eval().
returns a minified version of the given CSS Code
my $MinifiedCSS = $LoaderObject->MinifyCSS( Code => $CSS );
Warning: this function may cause a die() if there are errors in the file, protect against that with eval().
returns a minified version of the given JavaScript Code.
my $MinifiedJS = $LoaderObject->MinifyJavaScript( Code => $JavaScript );
Warning: this function may cause a die() if there are errors in the file, protect against that with eval().
This function internally uses the CPAN module JavaScript::Minifier. As of version 1.05 of that module, there is an issue with regular expressions:
This will cause a die:
function test(s) { return /\d{1,2}/.test(s); }
A workaround is to enclose the regular expression in parentheses:
function test(s) { return (/\d{1,2}/).test(s); }
generates the loader cache files for all frontend modules.
my %GeneratedFiles = $LoaderObject->CacheGenerate();
deletes all the loader cache files.
Returns a list of deleted files.
my @DeletedFiles = $LoaderObject->CacheDelete();
This software is part of the OTRS project (https://otrs.org/).
This software comes with ABSOLUTELY NO WARRANTY. For details, see the enclosed file COPYING for license information (GPL). If you did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.