Version Description
- roll-back to previous battle-tested version of the CSS minifier (a.o. fixing a bug where colors in filenames were replaced by hex-values)
- tweaks to Autoptimize toolbar menu (visual + timeout of "delete cache" AJAX call)
- readme update
Download this release
Release Info
Developer | futtta |
Plugin | Autoptimize |
Version | 2.2.2 |
Comparing to | |
See all releases |
Code changes from version 2.2.1 to 2.2.2
- autoptimize.php +4 -4
- classes/static/toolbar.css +4 -0
- classes/static/toolbar.js +1 -1
- classlesses/autoptimizeSpeedupper.php +4 -4
- readme.txt +43 -14
autoptimize.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Autoptimize
|
4 |
Plugin URI: http://autoptimize.com/
|
5 |
Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
|
6 |
-
Version: 2.2.
|
7 |
Author: Frank Goossens (futtta)
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Domain Path: localization/
|
@@ -121,8 +121,8 @@ function autoptimize_start_buffering() {
|
|
121 |
$ao_noptimize = false;
|
122 |
|
123 |
// noptimize in qs to get non-optimized page for debugging
|
124 |
-
if (array_key_exists("ao_noptimize",$_GET)) {
|
125 |
-
if ( ($_GET["ao_noptimize"]==="1") && (apply_filters('autoptimize_filter_honor_qs_noptimize',true)) ) {
|
126 |
$ao_noptimize = true;
|
127 |
}
|
128 |
}
|
@@ -199,7 +199,7 @@ function autoptimize_start_buffering() {
|
|
199 |
}
|
200 |
} else {
|
201 |
if (!class_exists('CSSmin')) {
|
202 |
-
@include(AUTOPTIMIZE_PLUGIN_DIR.'classes/external/php/yui-php-cssmin-2.4.8-
|
203 |
}
|
204 |
}
|
205 |
if ( ! defined( 'COMPRESS_CSS' )) {
|
3 |
Plugin Name: Autoptimize
|
4 |
Plugin URI: http://autoptimize.com/
|
5 |
Description: Optimizes your website, concatenating the CSS and JavaScript code, and compressing it.
|
6 |
+
Version: 2.2.2
|
7 |
Author: Frank Goossens (futtta)
|
8 |
Author URI: http://blog.futtta.be/
|
9 |
Domain Path: localization/
|
121 |
$ao_noptimize = false;
|
122 |
|
123 |
// noptimize in qs to get non-optimized page for debugging
|
124 |
+
if (array_key_exists("ao_noptimize",$_GET) || array_key_exists("ao_noptirocket",$_GET)) {
|
125 |
+
if ( ( ($_GET["ao_noptimize"]==="1") || ($_GET["ao_noptirocket"]==="1") ) && (apply_filters('autoptimize_filter_honor_qs_noptimize',true)) ) {
|
126 |
$ao_noptimize = true;
|
127 |
}
|
128 |
}
|
199 |
}
|
200 |
} else {
|
201 |
if (!class_exists('CSSmin')) {
|
202 |
+
@include(AUTOPTIMIZE_PLUGIN_DIR.'classes/external/php/yui-php-cssmin-2.4.8-4_fgo.php');
|
203 |
}
|
204 |
}
|
205 |
if ( ! defined( 'COMPRESS_CSS' )) {
|
classes/static/toolbar.css
CHANGED
@@ -240,3 +240,7 @@
|
|
240 |
{
|
241 |
border-radius : 50% !important;
|
242 |
}
|
|
|
|
|
|
|
|
240 |
{
|
241 |
border-radius : 50% !important;
|
242 |
}
|
243 |
+
|
244 |
+
/* fixes for toolbar on frontend for other themes messing things up */
|
245 |
+
#wp-admin-bar-autoptimize tr{border:0 !important}
|
246 |
+
#wp-admin-bar-autoptimize td{background-color:#32373c !important}
|
classes/static/toolbar.js
CHANGED
@@ -58,7 +58,7 @@ jQuery( document ).ready(function()
|
|
58 |
data : {'action':action, 'nonce':autoptimize_ajax_object.nonce},
|
59 |
dataType : 'json',
|
60 |
cache : false,
|
61 |
-
timeout :
|
62 |
success : function( cleared )
|
63 |
{
|
64 |
// Remove the Autoptimize Loading Modal
|
58 |
data : {'action':action, 'nonce':autoptimize_ajax_object.nonce},
|
59 |
dataType : 'json',
|
60 |
cache : false,
|
61 |
+
timeout : 9000,
|
62 |
success : function( cleared )
|
63 |
{
|
64 |
// Remove the Autoptimize Loading Modal
|
classlesses/autoptimizeSpeedupper.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
|
7 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
8 |
|
9 |
-
function
|
10 |
$md5hash = "snippet_".md5($jsin);
|
11 |
$ccheck = new autoptimizeCache($md5hash,'js');
|
12 |
if($ccheck->check()) {
|
@@ -48,7 +48,7 @@ function ao_js_snippetcache($jsin,$jsfilename) {
|
|
48 |
return $scriptsrc;
|
49 |
}
|
50 |
|
51 |
-
function
|
52 |
$md5hash = "snippet_".md5($cssin);
|
53 |
$ccheck = new autoptimizeCache($md5hash,'css');
|
54 |
if($ccheck->check()) {
|
@@ -97,7 +97,7 @@ function ao_js_speedup_cleanup($jsin) {
|
|
97 |
return trim($jsin);
|
98 |
}
|
99 |
|
100 |
-
add_filter('autoptimize_css_individual_style','
|
101 |
-
add_filter('autoptimize_js_individual_script','
|
102 |
add_filter('autoptimize_css_after_minify','ao_css_speedup_cleanup',10,1);
|
103 |
add_filter('autoptimize_js_after_minify','ao_js_speedup_cleanup',10,1);
|
6 |
|
7 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
8 |
|
9 |
+
function ao_js_snippetcacher($jsin,$jsfilename) {
|
10 |
$md5hash = "snippet_".md5($jsin);
|
11 |
$ccheck = new autoptimizeCache($md5hash,'js');
|
12 |
if($ccheck->check()) {
|
48 |
return $scriptsrc;
|
49 |
}
|
50 |
|
51 |
+
function ao_css_snippetcacher($cssin,$cssfilename) {
|
52 |
$md5hash = "snippet_".md5($cssin);
|
53 |
$ccheck = new autoptimizeCache($md5hash,'css');
|
54 |
if($ccheck->check()) {
|
97 |
return trim($jsin);
|
98 |
}
|
99 |
|
100 |
+
add_filter('autoptimize_css_individual_style','ao_css_snippetcacher',10,2);
|
101 |
+
add_filter('autoptimize_js_individual_script','ao_js_snippetcacher',10,2);
|
102 |
add_filter('autoptimize_css_after_minify','ao_css_speedup_cleanup',10,1);
|
103 |
add_filter('autoptimize_js_after_minify','ao_js_speedup_cleanup',10,1);
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Autoptimize ===
|
2 |
Contributors: futtta, optimizingmatters, turl
|
3 |
-
Tags: css,
|
4 |
Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.2.
|
8 |
|
9 |
Autoptimize speeds up your website and helps you save bandwidth by aggregating and minimizing JS, CSS and HTML.
|
10 |
|
@@ -41,9 +41,17 @@ HTTP/2 is a great step forward for sure, reducing the impact of multiple request
|
|
41 |
|
42 |
Although Autoptimize comes without any warranties, it will in general work flawlessly if you configure it correctly. See "Troubleshooting" below for info on how to configure in case of problems.
|
43 |
|
44 |
-
= Why
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
With the default Autoptimize configuration
|
47 |
|
48 |
= What is the use of "inline and defer CSS"? =
|
49 |
|
@@ -61,7 +69,7 @@ Back in the days CSS optimization was easy; put all CSS in your head, aggregatin
|
|
61 |
|
62 |
Inlining all CSS has one clear advantage (better PageSpeed score) and one big disadvantage; your base HTML-page gets significantly bigger and if the amount of CSS is big, Pagespeed Insights will complain of "roundtrip times". Also when looking at a test that includes multiple requests (let's say 5 pages), performance will be worse, as the CSS-payload is sent over again and again whereas normally the separate CSS-files would not need to be sent any more as they would be in cache.
|
63 |
|
64 |
-
So the choice should be based on your answer to some site-specific questions; how much CSS do you have? How many pages per visit do your visitors request? If you have a lot of CSS
|
65 |
|
66 |
You can find more information on this topic [in this blog post](http://blog.futtta.be/2014/02/13/should-you-inline-or-defer-blocking-css/).
|
67 |
|
@@ -76,22 +84,38 @@ Instead you can keep the cache size at an acceptable level by either:
|
|
76 |
|
77 |
Despite above objections, there are 3rd party solutions to automatically purge the AO cache, e.g. using [this code](https://wordpress.org/support/topic/contribution-autoptimize-cache-size-under-control-by-schedule-auto-cache-purge/) or [this plugin](https://wordpress.org/plugins/bi-clean-cache/), but for reasons above these are to be used only if you really know what you're doing.
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
= So should I aggregate inline CSS/ JS? =
|
80 |
|
81 |
-
Before Autoptimize 2.0.0, inline code was always optimized with all CSS pushed in the head-section and all JS at the end with a defer-flag. This often caused 2 problems; the priority of inline CSS got lost and inline JS could contain page- or request-specific code which broke Autoptimize's caching mechanism leading to too many cached files and the minification running over and over. This is why as from
|
82 |
|
83 |
= What can I do with the API? =
|
84 |
|
85 |
-
A whole lot; there are filters you can use to conditionally disable Autoptimize per request, to change the CSS- and JS-excludes, to change the limit for CSS background-images to be inlined in the CSS, to define what JS-files are moved behind the aggregated one, to change the defer-attribute on the aggregated JS script-tag, ... There are examples for
|
86 |
|
87 |
= How can I use the code in autoptimize_helper.php_example? =
|
88 |
|
89 |
Although you could add the code to your theme's functions.php, it would get overwritten with your next theme update. Therefor it is better to either create a helper plugin of your own or to simply use [the Code Snippets plugin](https://wordpress.org/plugins/code-snippets/) to manage any custom code.
|
90 |
|
91 |
-
= Why is jquery.js not optimized =
|
92 |
-
|
93 |
-
Starting from AO 2.1 WordPress core's jquery.js is not optimized for the simple reason a lot of popular plugins inject inline JS that is not aggregated either (due to possible cache size issues with unique code in inline JS) which relies on jquery being available, so excluding jquery.js ensures that most sites will work out of the box. If you want optimize jquery as well, you can remove it from the JS optimization exclusion-list (you might have to enable "also aggregate inline JS" as well or switch to "force JS in head").
|
94 |
-
|
95 |
= How does CDN work? =
|
96 |
|
97 |
Starting from version 1.7.0, CDN is activated upon entering the CDN blog root directory (e.g. http://cdn.example.net/wordpress/). If that URL is present, it will used for all Autoptimize-generated files (i.e. aggregated CSS and JS), including background-images in the CSS (when not using data-uri's).
|
@@ -224,8 +248,13 @@ Just [fork Autoptimize on Github](https://github.com/futtta/autoptimize) and cod
|
|
224 |
|
225 |
== Changelog ==
|
226 |
|
|
|
|
|
|
|
|
|
|
|
227 |
= 2.2.1 =
|
228 |
-
* fix for images in CSS not all being translated to correct path, leading to 404’s as reported by Jeff Inho
|
229 |
* fix for "[] operator not supported for strings" error in PHP7.1 as reported by falk-wussow.de
|
230 |
* fix for security hash busting AO's cache in some cases (esp. in 2.1.1)
|
231 |
|
@@ -242,7 +271,7 @@ Just [fork Autoptimize on Github](https://github.com/futtta/autoptimize) and cod
|
|
242 |
* tested and confirmed working in WordPress 4.8
|
243 |
|
244 |
= 2.1.2 =
|
245 |
-
* fix for security hash busting AO's cache
|
246 |
* identical to 2.1.0 except for the security fix backported from 2.2.0
|
247 |
|
248 |
= 2.1.1 =
|
1 |
=== Autoptimize ===
|
2 |
Contributors: futtta, optimizingmatters, turl
|
3 |
+
Tags: css, javascript, optimize, minify, performance
|
4 |
Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 4.9
|
7 |
+
Stable tag: 2.2.2
|
8 |
|
9 |
Autoptimize speeds up your website and helps you save bandwidth by aggregating and minimizing JS, CSS and HTML.
|
10 |
|
41 |
|
42 |
Although Autoptimize comes without any warranties, it will in general work flawlessly if you configure it correctly. See "Troubleshooting" below for info on how to configure in case of problems.
|
43 |
|
44 |
+
= Why is jquery.js not optimized =
|
45 |
+
|
46 |
+
Starting from AO 2.1 WordPress core's jquery.js is not optimized for the simple reason a lot of popular plugins inject inline JS that is not aggregated either (due to possible cache size issues with unique code in inline JS) which relies on jquery being available, so excluding jquery.js ensures that most sites will work out of the box. If you want optimize jquery as well, you can remove it from the JS optimization exclusion-list (you might have to enable "also aggregate inline JS" as well or switch to "force JS in head").
|
47 |
+
|
48 |
+
= Why is Autoptimized JS render blocking? =
|
49 |
+
|
50 |
+
If not "forced in head", Autoptimized JS is not render blocking as it has the "defer" flag added. It is however possible another plugin removes the "defer"-flag. Speed Booster Pack was reported doing this, but [the behavior has not been confirmed yet](https://wordpress.org/support/topic/speed-booster-pack-autoptimized-js-defer-flag/).
|
51 |
+
|
52 |
+
= Why is the autoptimized CSS still called out as render blocking? =
|
53 |
|
54 |
+
With the default Autoptimize configuration the CSS is linked in the head, which is a safe default but has Google PageSpeed Insights complaining. You can look into "inline all CSS" (easy) or "inline and defer CSS" (better) which are explained in this FAQ as well.
|
55 |
|
56 |
= What is the use of "inline and defer CSS"? =
|
57 |
|
69 |
|
70 |
Inlining all CSS has one clear advantage (better PageSpeed score) and one big disadvantage; your base HTML-page gets significantly bigger and if the amount of CSS is big, Pagespeed Insights will complain of "roundtrip times". Also when looking at a test that includes multiple requests (let's say 5 pages), performance will be worse, as the CSS-payload is sent over again and again whereas normally the separate CSS-files would not need to be sent any more as they would be in cache.
|
71 |
|
72 |
+
So the choice should be based on your answer to some site-specific questions; how much CSS do you have? How many pages per visit do your visitors request? If you have a lot of CSS or a high number of pages/ visit, it's probably not a good idea to inline all CSS.
|
73 |
|
74 |
You can find more information on this topic [in this blog post](http://blog.futtta.be/2014/02/13/should-you-inline-or-defer-blocking-css/).
|
75 |
|
84 |
|
85 |
Despite above objections, there are 3rd party solutions to automatically purge the AO cache, e.g. using [this code](https://wordpress.org/support/topic/contribution-autoptimize-cache-size-under-control-by-schedule-auto-cache-purge/) or [this plugin](https://wordpress.org/plugins/bi-clean-cache/), but for reasons above these are to be used only if you really know what you're doing.
|
86 |
|
87 |
+
= Upon updating Autoptimize can't be reactivated =
|
88 |
+
|
89 |
+
I have not been able to reproduce this, but had 2 users reporting that they had to temporarily disable W3 Total Cache to be able to re-activate the updated Autoptimize. No idea why this is happening, but this might help if you encounter that problem.
|
90 |
+
|
91 |
+
= "Clear cache" doesn't seem to work? =
|
92 |
+
|
93 |
+
When clicking the "Delete Cache" link in the Autoptimize dropdown in the admin toolbar, you might to get a "Your cache might not have been purged successfully". In that case go to Autoptimizes setting page and click the "Save changes & clear cache"-button.
|
94 |
+
|
95 |
+
Moreover don't worry if your cache never is down to 0 files/ 0KB, as Autoptimize (as from version 2.2) will automatically preload the cache immediately after it has been cleared to speed further minification significantly up.
|
96 |
+
|
97 |
+
= Can I still use Cloudflare's Rocket Loader? =
|
98 |
+
|
99 |
+
Cloudflare Rocket Loader is a pretty advanced but invasive way to make JavaScript non-render-blocking, which [Cloudflare still considers Beta](https://wordpress.org/support/topic/rocket-loader-breaking-onload-js-on-linked-css/#post-9263738). Sometimes Autoptimize & Rocket Loader work together, sometimes they don't. The best approach is to disable Rocket Loader, configure Autoptimize and re-enable Rocket Loader (if you think it can help) after that and test if everything still works.
|
100 |
+
|
101 |
+
At the moment (June 2017) it seems RocketLoader might break AO's "inline & defer CSS", which is based on [Filamentgroup’s loadCSS](https://github.com/filamentgroup/loadCSS), resulting in the deferred CSS not loading.
|
102 |
+
|
103 |
+
= I tried Autoptimize but my Google Pagespeed Scored barely improved =
|
104 |
+
|
105 |
+
Autoptimize is not a simple "fix my Pagespeed-problems" plugin; it "only" aggregates & minifies (local) JS & CSS and allows for some nice extra's as removing Google Fonts and deferring the loading of the CSS. As such Autoptimize will allow you to improve your performance (load time measured in seconds) and will probably also help you tackle some specific Pagespeed warnings. If you want to improve further, you will probably also have to look into e.g. page caching, image optimization and your webserver configuration, which will improve real performance (again, load time as measured by e.g. https://webpagetest.org) and your "performance best practise" pagespeed ratings.
|
106 |
+
|
107 |
= So should I aggregate inline CSS/ JS? =
|
108 |
|
109 |
+
Before Autoptimize 2.0.0, inline code was always optimized with all CSS pushed in the head-section and all JS at the end with a defer-flag. This often caused 2 problems; the priority of inline CSS got lost and inline JS could contain page- or request-specific code which broke Autoptimize's caching mechanism leading to too many cached files and the minification running over and over. This is why as from AO 2.0 by default inline code is not optimized (except for those upgrading from previous versions). Additionally, to avoid inline JS breaking because jquery is not available, `js/jquery/jquery.js` is excluded by default.
|
110 |
|
111 |
= What can I do with the API? =
|
112 |
|
113 |
+
A whole lot; there are filters you can use to conditionally disable Autoptimize per request, to change the CSS- and JS-excludes, to change the limit for CSS background-images to be inlined in the CSS, to define what JS-files are moved behind the aggregated one, to change the defer-attribute on the aggregated JS script-tag, ... There are examples for some filters in autoptimize_helper.php_example and in this FAQ.
|
114 |
|
115 |
= How can I use the code in autoptimize_helper.php_example? =
|
116 |
|
117 |
Although you could add the code to your theme's functions.php, it would get overwritten with your next theme update. Therefor it is better to either create a helper plugin of your own or to simply use [the Code Snippets plugin](https://wordpress.org/plugins/code-snippets/) to manage any custom code.
|
118 |
|
|
|
|
|
|
|
|
|
119 |
= How does CDN work? =
|
120 |
|
121 |
Starting from version 1.7.0, CDN is activated upon entering the CDN blog root directory (e.g. http://cdn.example.net/wordpress/). If that URL is present, it will used for all Autoptimize-generated files (i.e. aggregated CSS and JS), including background-images in the CSS (when not using data-uri's).
|
248 |
|
249 |
== Changelog ==
|
250 |
|
251 |
+
= 2.2.2 =
|
252 |
+
* roll-back to previous battle-tested version of the CSS minifier (a.o. fixing a bug where colors in filenames were replaced by hex-values)
|
253 |
+
* tweaks to Autoptimize toolbar menu (visual + timeout of "delete cache" AJAX call)
|
254 |
+
* readme update
|
255 |
+
|
256 |
= 2.2.1 =
|
257 |
+
* fix for images being referenced in CSS not all being translated to correct path, leading to 404’s as reported by Jeff Inho
|
258 |
* fix for "[] operator not supported for strings" error in PHP7.1 as reported by falk-wussow.de
|
259 |
* fix for security hash busting AO's cache in some cases (esp. in 2.1.1)
|
260 |
|
271 |
* tested and confirmed working in WordPress 4.8
|
272 |
|
273 |
= 2.1.2 =
|
274 |
+
* fix for security hash busting AO's cache in some cases (esp. in 2.1.1)
|
275 |
* identical to 2.1.0 except for the security fix backported from 2.2.0
|
276 |
|
277 |
= 2.1.1 =
|