Arjan Optimize helps you optimize all of your static assets with a single command. It takes into account several of the modern web dev directives and uses some of the most popular node modules for minification/compression of assets with a couple of neat features of its own. For more info read the docs
Arjan optimize scans your current directory recursively and for each file with a different module depending on the files MIME type. Arjan Optimize uses:
Input | Module used | Output | options | reason used |
---|---|---|---|---|
html | html-minifier | html | options | best compression |
css | csso | css | options | best overall size+speed+compression |
js | terser | js | Parse, Compress, Mangle | support for ES6, best speed & compression |
svg | svgo | svg | options | most widely used open source option |
jpeg | sharp | jpeg | options | fastest option |
png | sharp | png | options | fastest option |
webp | sharp | webp | options | fastest option |
gif | sharp | png | options | fastest option |
tiff | sharp | tiff | options | fastest option |
The webp option in Arjan Optimize does 2 things:
- converts all your images to webp using sharp and saves them (without overwritting images in original format)
- In the HTML files, it replaces each img tag with a picture tag that holds both its original compressed version and its webp version.
Because webp is a relatively new format, it is not supported by all browsers. The picture tag is a solution that allows unsupported browsers to fall back to the original version of the image. This article goes more in depth on webp and the picture tag.
suppose we have the following image tag:
<img src="img/arjan-logo.png" class="img-fluid">
this will be replaced by:
<picture>
<source type="image/webp" srcset="img/arjan-logo.png">
<source type="image/png" srcset="img/arjan-logo.png">
<img src="img/arjan-logo.png" class="img-fluid">
</picture>
arjan optimize SITENAME [FILENAME] --img --webp --responsive --html --css --rcss --js
USAGE
$ arjan optimize [FILENAME]
ARGUMENTS
FILENAME name of the file i.e. index.html
OPTIONS
-c, --css minifiy css using cssnano
-h, --html compress html using html-minifier
-i, --images compress images and if possible maintain the format, otherwise its converted to png.
-j, --js minify js using uglify js
-w, --webp saves a webp version of each image, then replaces each image instance in the html files with a picture tag.