Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

A WordPress plugin for Themosis that provides a WP CLI method to generate critical CSS.

License

Notifications You must be signed in to change notification settings

djgadd/themosis-criticalcss

Repository files navigation

Themosis Critical CSS

A WordPress plugin for Themosis that implements kalfheim/critical-css to generate critical CSS in WordPress. You'll need to have wp-cli setup to run it, and it'll also need to be present in production to new/changed posts. Also relies on keltiecochrane/themosis-illuminate implementation of config and files, and uses keltiecochrane/themosis-logger for logging.

It will generate CSS for mobile, tablet and desktop devices, which will be served as appropriate by browser sniffing. It will automatically modify style tags to set them to rel="preload" and uses loadCSS to polyfill browsers that don't support preloading.

This plugin will set a cookie to determine users that have/haven't been served the CSS previously (to avoid inflated page loads for users that have a cached copy of your CSS.) You may need to add a notice or override this functionality as is appropriate to local laws regarding cookies.

Install

From your projects base path run: -

npm install critical --save

Require the package in composer: -

composer require keltiecochrane/themosis-criticalcss

Copy the config/criticalcss.php file into your config folder.

Activate the plugin in WordPress.

Use

You'll need to have wp-cli installed, to generate CSS run: -

wp critical-css generate

To clear generated CSS run: -

wp critical-css clear

Support

This plugin is provided as is, though we'll endeavour to help where we can.

Contributing

Any contributions would be encouraged and much appreciated, you can contribute by: -

  • Reporting bugs
  • Suggesting features
  • Sending pull requests

About

A WordPress plugin for Themosis that provides a WP CLI method to generate critical CSS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages