From ec26681ec8021ebcbd4c394ae29d60db65cb1d46 Mon Sep 17 00:00:00 2001 From: futtta Date: Thu, 28 May 2020 11:06:35 +0200 Subject: [PATCH] @sjoerdlinders we'll have to put this behind a default false filter: $minified_url can also be false if the file is minified already (as per filename). emptying $new_tag for those results in the non-aggregated CSS not being preloaded if "inline & defer" is on. --- classes/autoptimizeScripts.php | 5 +++-- classes/autoptimizeStyles.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/autoptimizeScripts.php b/classes/autoptimizeScripts.php index f8148256..db972a82 100644 --- a/classes/autoptimizeScripts.php +++ b/classes/autoptimizeScripts.php @@ -345,8 +345,9 @@ public function read( $options ) if ( ! empty( $minified_url ) ) { // Replace original URL with minified URL from cache. $new_tag = str_replace( $url, $minified_url, $new_tag ); - } else { - // Remove the original script tag, because cache content is empty. + } elseif ( apply_filters( 'autoptimize_filter_ccsjs_remove_empty_minified_url', false ) ) { + // Remove the original script tag, because cache content is empty but only if filter + // is trued because $minified_url is also false if original JS is minified already. $new_tag = ''; } } diff --git a/classes/autoptimizeStyles.php b/classes/autoptimizeStyles.php index d34eb79c..af43412d 100644 --- a/classes/autoptimizeStyles.php +++ b/classes/autoptimizeStyles.php @@ -343,8 +343,9 @@ public function read( $options ) if ( ! empty( $minified_url ) ) { // Replace orig URL with cached minified URL. $new_tag = str_replace( $url, $minified_url, $tag ); - } else { - // Remove the original style tag, because cache content is empty. + } elseif ( apply_filters( 'autoptimize_filter_ccsjs_remove_empty_minified_url', false ) ) { + // Remove the original style tag, because cache content is empty but only if + // filter is true-ed because $minified_url is also false if file is minified already. $new_tag = ''; } }