carbon/compression

Output compression and minification for Neos CMS

2.0.0 2019-09-24 08:02 UTC

This package is auto-updated.

Last update: 2020-09-05 11:43:13 UTC


README

Latest Stable Version Total Downloads License GitHub forks GitHub stars GitHub watchers

Carbon.Compression Package for Neos CMS

This package minify the head and body section HTML of the Neos.Neos:Page prototype using pure regex. The regex can be adjusted in Settings.yaml. The difference between the minification from this package and wyrihaximus/html-compress is that this package inserts a blank space between the tags. This behavior prevents some browser bugs, especially Safari and SVG issues. If you set your templates with AFX, you might not need this package.

Installation

Most of the time you have to make small adjustments to a package (e.g. configuration in Settings.yaml). Because of that, it is important to add the corresponding package to the composer from your theme package. Mostly this is the site packages located under Packages/Sites/. To install it correctly go to your theme package (e.g.Packages/Sites/Foo.Bar) and run following command:

composer require carbon/compression --no-update

The --no-update command prevent the automatic update of the dependencies. After the package was added to your theme composer.json, go back to the root of the Neos installation and run composer update. Et voilà! Your desired package is now installed correctly.

Usage

As soon as the package is installed, the Neos.Neos:Page prototype is amended with @process instructions on the head and body elements. This will minify and "regular" output without any further steps to take.

Adjust minification

To remove the default minification, simply override:

prototype(Neos.Neos:Page) {
    head.@process.minify >
    body.@process.minify >
}

To compress specific parts, use the minification prototype like this:

something.@process.minify = Carbon.Compression:Minify