diff --git a/projects/plugins/boost/.gitattributes b/projects/plugins/boost/.gitattributes index a1ec69d2c57d0..54a7bd6d71d6b 100644 --- a/projects/plugins/boost/.gitattributes +++ b/projects/plugins/boost/.gitattributes @@ -13,7 +13,6 @@ vendor/automattic/** production-include vendor/composer/** production-include vendor/jetpack-autoloader/** production-include vendor/tedivm/** production-include -vendor/tubalmartin/** production-include vendor/matthiasmullie/** production-include vendor/wikimedia/aho-corasick/** production-include diff --git a/projects/plugins/boost/app/lib/class-minify.php b/projects/plugins/boost/app/lib/class-minify.php index 8608e4af4341d..73cde2f7f1cd4 100644 --- a/projects/plugins/boost/app/lib/class-minify.php +++ b/projects/plugins/boost/app/lib/class-minify.php @@ -9,19 +9,14 @@ namespace Automattic\Jetpack_Boost\Lib; +use MatthiasMullie\Minify\CSS as CSSMinifier; use MatthiasMullie\Minify\JS as JSMinifier; -use tubalmartin\CssMin\Minifier as CSSMinifier; /** * Class Minify */ class Minify { - /** - * @var CSSMinifier - Holds the CssMin\Minifier instance, for reuse on subsequent calls. - */ - private static $css_minifier; - /** * Strips whitespace from JavaScript scripts. * @@ -44,10 +39,13 @@ public static function js( $js ) { * Minifies the supplied CSS code, returning its minified form. */ public static function css( $css ) { - if ( ! self::$css_minifier ) { - self::$css_minifier = new CSSMinifier(); + try { + $minifier = new CSSMinifier( $css ); + $minified_css = $minifier->minify(); + } catch ( \Exception $e ) { + return $css; } - return self::$css_minifier->run( $css ); + return $minified_css; } } diff --git a/projects/plugins/boost/changelog/update-boost-minify-css-library b/projects/plugins/boost/changelog/update-boost-minify-css-library new file mode 100644 index 0000000000000..0ebb483a0aa90 --- /dev/null +++ b/projects/plugins/boost/changelog/update-boost-minify-css-library @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Concatenate CSS: Fixed cases where minification might cause a file to load slower. diff --git a/projects/plugins/boost/composer.json b/projects/plugins/boost/composer.json index 6e61bc7dac944..ec30d7a91d786 100644 --- a/projects/plugins/boost/composer.json +++ b/projects/plugins/boost/composer.json @@ -30,8 +30,7 @@ "automattic/jetpack-status": "@dev", "automattic/jetpack-sync": "@dev", "automattic/jetpack-wp-js-data-sync": "@dev", - "matthiasmullie/minify": "^1.3", - "tubalmartin/cssmin": "^4.1" + "matthiasmullie/minify": "^1.3" }, "require-dev": { "automattic/jetpack-changelogger": "@dev", diff --git a/projects/plugins/boost/composer.lock b/projects/plugins/boost/composer.lock index 89b3bf090b46b..6b47ff81a025e 100644 --- a/projects/plugins/boost/composer.lock +++ b/projects/plugins/boost/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b52098ae2e5a4e594034ec41fb2636e6", + "content-hash": "0ad50993accd8a26f9fd344099d8a588", "packages": [ { "name": "automattic/jetpack-a8c-mc-stats", @@ -2142,63 +2142,6 @@ "source": "https://github.com/matthiasmullie/path-converter/tree/1.1.3" }, "time": "2019-02-05T23:41:09+00:00" - }, - { - "name": "tubalmartin/cssmin", - "version": "v4.1.1", - "source": { - "type": "git", - "url": "https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port.git", - "reference": "3cbf557f4079d83a06f9c3ff9b957c022d7805cf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tubalmartin/YUI-CSS-compressor-PHP-port/zipball/3cbf557f4079d83a06f9c3ff9b957c022d7805cf", - "reference": "3cbf557f4079d83a06f9c3ff9b957c022d7805cf", - "shasum": "" - }, - "require": { - "ext-pcre": "*", - "php": ">=5.3.2" - }, - "require-dev": { - "cogpowered/finediff": "0.3.*", - "phpunit/phpunit": "4.8.*" - }, - "bin": [ - "cssmin" - ], - "type": "library", - "autoload": { - "psr-4": { - "tubalmartin\\CssMin\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Túbal Martín", - "homepage": "http://tubalmartin.me/" - } - ], - "description": "A PHP port of the YUI CSS compressor", - "homepage": "https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port", - "keywords": [ - "compress", - "compressor", - "css", - "cssmin", - "minify", - "yui" - ], - "support": { - "issues": "https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port/issues", - "source": "https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port" - }, - "time": "2018-01-15T15:26:51+00:00" } ], "packages-dev": [ diff --git a/projects/plugins/boost/serve-minified-content.php b/projects/plugins/boost/serve-minified-content.php index 59271179ad317..0fd83f7a655a9 100644 --- a/projects/plugins/boost/serve-minified-content.php +++ b/projects/plugins/boost/serve-minified-content.php @@ -3,10 +3,14 @@ if ( ! defined( 'JETPACK_BOOST_CONCAT_USE_WP' ) ) { define( 'JETPACK_BOOST_CONCAT_USE_WP', false ); - // Load CSSmin. - require_once __DIR__ . '/vendor/tubalmartin/cssmin/src/Colors.php'; - require_once __DIR__ . '/vendor/tubalmartin/cssmin/src/Utils.php'; - require_once __DIR__ . '/vendor/tubalmartin/cssmin/src/Minifier.php'; + // Load minification library. + require_once __DIR__ . '/vendor/matthiasmullie/minify/src/Exception.php'; + require_once __DIR__ . '/vendor/matthiasmullie/minify/src/Minify.php'; + require_once __DIR__ . '/vendor/matthiasmullie/minify/src/CSS.php'; + require_once __DIR__ . '/vendor/matthiasmullie/minify/src/JS.php'; + require_once __DIR__ . '/vendor/matthiasmullie/minify/src/Exceptions/BasicException.php'; + require_once __DIR__ . '/vendor/matthiasmullie/minify/src/Exceptions/FileImportException.php'; + require_once __DIR__ . '/vendor/matthiasmullie/minify/src/Exceptions/IOException.php'; } // Load minify library code.