NAME Mojolicious::Plugin::AssetPack - Compress and convert css, less, sass, javascript and coffeescript files VERSION 0.31 SYNOPSIS In your application: use Mojolicious::Lite; plugin 'AssetPack'; # define assets: $moniker => @real_assets app->asset('app.js' => '/js/foo.js', '/js/bar.js', '/js/baz.coffee'); app->asset('app.css' => '/css/foo.less', '/css/bar.scss', '/css/main.css'); # you can combine with assets from web app->asset('ie8.js' => ( 'http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.3.0/es5-shim.js', 'http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.3.0/es5-sham.js', 'http://code.jquery.com/jquery-1.11.0.js', '/js/myapp.js', )); app->start; In your template: %= asset 'app.js' %= asset 'app.css' Or if you want the asset inlined in the HTML: %= asset 'app.css', { inline => 1 } Or if you need to add the tags manually: % for my $asset (asset->get('app.js')) { %= javascript $asset % } See also "register". DESCRIPTION Mojolicious::Plugin::AssetPack is a Mojolicious plugin which can be used to cram multiple assets of the same type into one file. This means that if you have a lot of CSS files (.css, .less, .sass, ...) as input, the AssetPack can make one big CSS file as output. This is good, since it will often speed up the rendering of your page. The output file can even be minified, meaning you can save bandwidth and browser parsing time. The core preprocessors that are bundled with this module can handle CSS and JavaScript files, written in many languages. See Mojolicious::Plugin::AssetPack::Preprocessors for more details. Production mode This plugin will compress sass, less, css, javascript and coffeescript with the help of external applications on startup. The result will be one file with all the sources combined. This file is stored in "Packed directory". The files in the packed directory will have a checksum added to the filename which will ensure broken browsers request a new version once the file is changed. Example: