-
Notifications
You must be signed in to change notification settings - Fork 234
Description
Describe the bug
When the minify CSS option is turned on, the @import rules aren't combined into the current CSS file.
This is an important problem for performance:
- it creates useless HTTP requests
- The files needs to be preloaded to not decrease the PageSpeed Insight Grade
I did some tests on my side to know if the default behavior of the library was to combined @import rules.
The response is: YES
Please note that only internal @import rules are combined by the library. It means an @import rules from Google Fonts won't be merged.
I did a simple test on smashingcoding website. I minified this file which contains 2 @import rules:
http://smashingcoding.com/wp-content/plugins/forget-about-shortcode-buttons/public/css/button-styles.css
I used the last version of the library by using this code:
<?php
header('Content-type: text/css');
header('Cache-Control: max-age=31536000');
require_once 'minify/Minify.php';
require_once 'minify/CSS.php';
require_once 'path-converter/ConverterInterface.php';
require_once 'path-converter/Converter.php';
use MatthiasMullie\Minify;
$minifier = new Minify\CSS();
$minifier->add('wp-content/plugins/forget-about-shortcode-buttons/public/css/button-styles.css');
echo $minifier->minify();
The result is available here:
http://smashingcoding.com/minify.php
As you can notice the @import rules has been combined into the minified CSS file.
It means we have a problem into WP Rocket to be able to combine the @import rules.
/!\ The $maxImportSize variable doesn't have any relation with this problem. Increasing its value won't have any effect.
To Reproduce
Steps to reproduce the behavior:
- Go to smashingcoding.com
- Activate the Minify CSS option
- Check the source code of the CSS file which starts by http://smashingcoding.com/wp-content/cache/min/1/wp-content/plugins/forget-about-shortcode-buttons/public/css/button-styles-
- See error. The @import rules are still present
Expected behavior
The internal @import rules should be combined into the current CSS file.
Backlog Grooming (for WP Media dev team use only)
- Reproduce the problem
- Identify the root cause
- Scope a solution
- Estimate the effort