https://github.com/sayhellogmbh/autoptimize-critical-css-io
An adapter to connect https://github.com/nico-martin/critical-css-api with Autoptimize
https://github.com/sayhellogmbh/autoptimize-critical-css-io
Last synced: 3 months ago
JSON representation
An adapter to connect https://github.com/nico-martin/critical-css-api with Autoptimize
- Host: GitHub
- URL: https://github.com/sayhellogmbh/autoptimize-critical-css-io
- Owner: SayHelloGmbH
- Created: 2020-03-22T06:11:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T16:45:43.000Z (over 3 years ago)
- Last Synced: 2025-10-26T05:53:00.301Z (9 months ago)
- Language: PHP
- Size: 1.46 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 17
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Autoptimize - Critical CSS API
A WordPress Plugin that connects [Autoptimize](https://wordpress.org/plugins/autoptimize/) with the open source CriticalCSS generator [Critical CSS API](https://github.com/nico-martin/critical-css-api).
## conditonal Critical CSS
The Critical CSS follows a template hierarchy similar to the WordPress template hierarchy.
```
index.css
| singular.css
| | singular-{$post_type}.css
| | | singular-{$post_id}.css
| archive.css
| | archive-{$post_type}.css
| | archive-author.css
| | | archive-author-{$author_name}.css
| | archive-date.css
| | | archive-date-year.css
| | | archive-date-month.css
| | | archive-date-day.css
| | archvie-taxonomy.css
| | | archvie-taxonomy-{$taxonomy}.css
| | | | archvie-taxonomy-{$term_id}.css
| front-page.css
| 404.css
| search.css
```
The plugin allows you to create the Critical CSS for a specific page (as post meta box) or various fallbacks (on the settings page).
## Developers
### Filters
#### apiBaseURL
By default this plugin uses the hosted version of [Critical CSS API](https://github.com/nico-martin/critical-css-api) on https://api.critical-css.io. But if you want to use a self-hosted version you can change the API base url using `aoccssio/apiBaseURL`:
```php
function myplugin_api_base( $defaultAPIBase ) {
return 'https://myapibaseurl.com';
}
add_filter( 'aoccssio/apiBaseURL', 'myplugin_api_base' );
```
#### dimensions
```php
function myplugin_dimensions( $defaultDimensions ) {
return [
'desktop' => [
'width' => 1200,
'height' => 800,
],
'mobile' => [
'width' => 700,
'height' => 300,
],
];
}
add_filter( 'aoccssio/dimensions', 'myplugin_dimensions' )
```