Critical Path CSS compiler/cacher for SilverStripe

Installs: 9

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0


dev-master 2021-11-18 20:34 UTC

This package is auto-updated.

Last update: 2024-05-19 01:34:09 UTC


Assists in producing the Critical path CSS for every page of the website, including that code and postponing every other css. Uses penthouse to generate the CSS.

How it works

The module provides a dev task GenerateCriticalPathCSS that calls every Live page on the website, and processes the HTML with penthouse, caches the resulting CSS, injects the latter into pages' during regular requests HTML and postpones all the already inlcluded local(!) CSS files using a special javascript snippet.

If you choose to involve external CSS files (see Configuration below) they will be downloaded and stored in cache.


  • All the CSS files you want to involve must be included using Requirements::css() or Requirements::themedCSS().
  • Firefox doesn't seem to like the postponing of CSS files and will most likely not gain any real speed boost.


  • nodejs
  • yarn or npm

They are required to install penthouse after package installation.


Install via composer and do ?flush=1.

composer require --prefer-dist gurucomkz/silverstripe-critical-path-css "dev-master"

Install required packages inside the package's directory with yarn or npm.

cd vendor/gurucomkz/silverstripe-critical-path-css
yarn || npm


This is intended to be run on the target server.

sake dev/tasks/GenerateCriticalPathCSS

This task may take a lot of time depending on amount of pages on the website and effort required to produce their HTML. Please, note that since this command is executed in CLI caches produced by your web server are not applicable.


  # involve the external css files
  include_external: true # default: false
  # ensure these selectors are a part of the critical path CSS
  # see for 'forceInclude'
    - ".abc"
    - "#another"
    - "/\\.slick.*/"


  • Unit tests


Please create an issue or a PR for any bugs you've found, or features you're missing.

Special thanks