Autoptimize - Version 2.7.6

Version Description

  • fix for top frontend admin-bar being invisible when "inline & defer" is active.
  • fix for 3rd party CSS-files not being deferred when "inline & defer" is active.
  • small copy changes on Extra settings screen.
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 Autoptimize
Version 2.7.6
Comparing to
See all releases

Code changes from version 2.7.5 to 2.7.6

autoptimize.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Autoptimize
4
  * Plugin URI: https://autoptimize.com/
5
  * Description: Makes your site faster by optimizing CSS, JS, Images, Google fonts and more.
6
- * Version: 2.7.5
7
  * Author: Frank Goossens (futtta)
8
  * Author URI: https://autoptimize.com/
9
  * Text Domain: autoptimize
@@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
21
  exit;
22
  }
23
 
24
- define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.7.5' );
25
 
26
  // plugin_dir_path() returns the trailing slash!
27
  define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
3
  * Plugin Name: Autoptimize
4
  * Plugin URI: https://autoptimize.com/
5
  * Description: Makes your site faster by optimizing CSS, JS, Images, Google fonts and more.
6
+ * Version: 2.7.6
7
  * Author: Frank Goossens (futtta)
8
  * Author URI: https://autoptimize.com/
9
  * Text Domain: autoptimize
21
  exit;
22
  }
23
 
24
+ define( 'AUTOPTIMIZE_PLUGIN_VERSION', '2.7.6' );
25
 
26
  // plugin_dir_path() returns the trailing slash!
27
  define( 'AUTOPTIMIZE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
classes/autoptimizeExtra.php CHANGED
@@ -505,8 +505,8 @@ class autoptimizeExtra
505
  <?php // translators: "display:swap" should remain untranslated, will be shown in code tags. ?>
506
  <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="3" <?php checked( 3, $gfonts, true ); ?> ><?php echo __( 'Combine and link in head (fonts load fast but are render-blocking)', 'autoptimize' ) . ', ' . sprintf( __( 'includes %1$sdisplay:swap%2$s.', 'autoptimize' ), '<code>', '</code>' ); ?><br/>
507
  <?php // translators: "display:swap" should remain untranslated, will be shown in code tags. ?>
508
- <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="5" <?php checked( 5, $gfonts, true ); ?> ><?php echo __( 'Combine and preload in head (fonts load late, but are not render-blocking)', 'autoptimize' ) . ', ' . sprintf( __( 'includes %1$sdisplay:swap%2$s.', 'autoptimize' ), '<code>', '</code>' ); ?><br/>
509
- <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="4" <?php checked( 4, $gfonts, true ); ?> ><?php _e( 'Combine and load fonts asynchronously with <a href="https://github.com/typekit/webfontloader#readme" target="_blank">webfont.js</a>', 'autoptimize' ); ?><br/>
510
  </td>
511
  </tr>
512
  <tr>
@@ -541,7 +541,7 @@ class autoptimizeExtra
541
  // translators: link points Async Javascript settings page.
542
  printf( __( 'You have "Async JavaScript" installed, %1$sconfiguration of async javascript is best done there%2$s.', 'autoptimize' ), '<a href="' . 'options-general.php?page=async-javascript' . '">', '</a>' );
543
  } else {
544
- ?>
545
  <input type='text' style='width:80%' name='autoptimize_extra_settings[autoptimize_extra_text_field_3]' value='<?php if ( array_key_exists( 'autoptimize_extra_text_field_3', $options ) ) { echo esc_attr( $options['autoptimize_extra_text_field_3'] ); } ?>'>
546
  <br />
547
  <?php
505
  <?php // translators: "display:swap" should remain untranslated, will be shown in code tags. ?>
506
  <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="3" <?php checked( 3, $gfonts, true ); ?> ><?php echo __( 'Combine and link in head (fonts load fast but are render-blocking)', 'autoptimize' ) . ', ' . sprintf( __( 'includes %1$sdisplay:swap%2$s.', 'autoptimize' ), '<code>', '</code>' ); ?><br/>
507
  <?php // translators: "display:swap" should remain untranslated, will be shown in code tags. ?>
508
+ <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="5" <?php checked( 5, $gfonts, true ); ?> ><?php echo __( 'Combine and link deferred in head (fonts load late, but are not render-blocking)', 'autoptimize' ) . ', ' . sprintf( __( 'includes %1$sdisplay:swap%2$s.', 'autoptimize' ), '<code>', '</code>' ); ?><br/>
509
+ <input type="radio" name="autoptimize_extra_settings[autoptimize_extra_radio_field_4]" value="4" <?php checked( 4, $gfonts, true ); ?> ><?php echo __( 'Combine and load fonts asynchronously with <a href="https://github.com/typekit/webfontloader#readme" target="_blank">webfont.js</a>', 'autoptimize' ) . ' ' . __( '(deprecated)', 'autoptimize' ); ?><br/>
510
  </td>
511
  </tr>
512
  <tr>
541
  // translators: link points Async Javascript settings page.
542
  printf( __( 'You have "Async JavaScript" installed, %1$sconfiguration of async javascript is best done there%2$s.', 'autoptimize' ), '<a href="' . 'options-general.php?page=async-javascript' . '">', '</a>' );
543
  } else {
544
+ ?>
545
  <input type='text' style='width:80%' name='autoptimize_extra_settings[autoptimize_extra_text_field_3]' value='<?php if ( array_key_exists( 'autoptimize_extra_text_field_3', $options ) ) { echo esc_attr( $options['autoptimize_extra_text_field_3'] ); } ?>'>
546
  <br />
547
  <?php
classes/autoptimizeStyles.php CHANGED
@@ -385,24 +385,28 @@ class autoptimizeStyles extends autoptimizeBase
385
  // Defer single CSS if "inline & defer" is ON and there is inline CSS.
386
  if ( ! empty( $tag ) && false === strpos( $tag, ' onload=' ) && $this->defer && ! empty( $this->defer_inline ) && apply_filters( 'autoptimize_filter_css_defer_excluded', true, $tag ) ) {
387
  // get media attribute and based on that create onload JS attribute value.
388
- if ( false !== strpos( $tag, 'media=' ) ) {
389
- preg_match( '#media=(?:"|\')([^>]*)(?:"|\')#Ui', $tag, $_medias );
390
- $_media = $_medias[1];
391
- } else {
392
- $_media = 'all';
393
  }
394
- $_preload_onload = autoptimizeConfig::get_ao_css_preload_onload( $_media );
395
 
396
- // Adapt original <link> element for CSS to be preloaded and add <noscript>-version for fallback.
397
- $new_tag = '<noscript>' . autoptimizeUtils::remove_id_from_node( $tag ) . '</noscript>' . str_replace(
398
- $_medias[0],
399
- "media='print' onload=\"" . $_preload_onload . '"',
400
- $tag
401
- );
402
 
403
- // Optionally (but default false) preload the (excluded) CSS-file.
404
- if ( apply_filters( 'autoptimize_fitler_css_preload_and_print', false ) && 'none' !== $url ) {
405
- $new_tag = '<link rel="preload" as="stylesheet" href="' . $url . '"/>' . $new_tag;
 
 
 
 
 
 
 
 
 
 
 
406
  }
407
 
408
  return $new_tag;
@@ -1020,8 +1024,8 @@ class autoptimizeStyles extends autoptimizeBase
1020
  $url = $this->url_replace_cdn( $url );
1021
 
1022
  // Add the stylesheet either deferred (import at bottom) or normal links in head.
1023
- if ( $this->defer ) {
1024
- $preload_onload = autoptimizeConfig::get_ao_css_preload_onload();
1025
 
1026
  $preload_css_block .= '<link rel="stylesheet" media="print" href="' . $url . '" onload="' . $preload_onload . '" />';
1027
  if ( apply_filters( 'autoptimize_fitler_css_preload_and_print', false ) ) {
385
  // Defer single CSS if "inline & defer" is ON and there is inline CSS.
386
  if ( ! empty( $tag ) && false === strpos( $tag, ' onload=' ) && $this->defer && ! empty( $this->defer_inline ) && apply_filters( 'autoptimize_filter_css_defer_excluded', true, $tag ) ) {
387
  // get media attribute and based on that create onload JS attribute value.
388
+ if ( false === strpos( $tag, 'media=' ) ) {
389
+ $tag = str_replace( '<link', "<link media='all'", $tag );
 
 
 
390
  }
 
391
 
392
+ preg_match( '#media=(?:"|\')([^>]*)(?:"|\')#Ui', $tag, $_medias );
393
+ $_media = $_medias[1];
394
+ $_preload_onload = autoptimizeConfig::get_ao_css_preload_onload( $_media );
 
 
 
395
 
396
+ if ( 'print' !== $_media ) {
397
+ // If not media=print, adapt original <link> element for CSS to be preloaded and add <noscript>-version for fallback.
398
+ $new_tag = '<noscript>' . autoptimizeUtils::remove_id_from_node( $tag ) . '</noscript>' . str_replace(
399
+ $_medias[0],
400
+ "media='print' onload=\"" . $_preload_onload . '"',
401
+ $tag
402
+ );
403
+
404
+ // Optionally (but default false) preload the (excluded) CSS-file.
405
+ if ( apply_filters( 'autoptimize_fitler_css_preload_and_print', false ) && 'none' !== $url ) {
406
+ $new_tag = '<link rel="preload" as="stylesheet" href="' . $url . '"/>' . $new_tag;
407
+ }
408
+ } else {
409
+ $new_tag = $tag;
410
  }
411
 
412
  return $new_tag;
1024
  $url = $this->url_replace_cdn( $url );
1025
 
1026
  // Add the stylesheet either deferred (import at bottom) or normal links in head.
1027
+ if ( $this->defer && 'print' !== $media ) {
1028
+ $preload_onload = autoptimizeConfig::get_ao_css_preload_onload( $media );
1029
 
1030
  $preload_css_block .= '<link rel="stylesheet" media="print" href="' . $url . '" onload="' . $preload_onload . '" />';
1031
  if ( apply_filters( 'autoptimize_fitler_css_preload_and_print', false ) ) {
readme.txt CHANGED
@@ -5,14 +5,14 @@ Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
5
  Requires at least: 4.9
6
  Tested up to: 5.5
7
  Requires PHP: 5.6
8
- Stable tag: 2.7.5
9
 
10
  Autoptimize speeds up your website by optimizing JS, CSS, images (incl. lazy-load), HTML and Google Fonts, asyncing JS, removing emoji cruft and more.
11
 
12
  == Description ==
13
 
14
  Autoptimize makes optimizing your site really easy. It can aggregate, minify and cache scripts and styles, injects CSS in the page head by default but can also inline critical CSS and defer the aggregated full CSS, moves and defers scripts to the footer and minifies HTML. You can optimize and lazy-load images, optimize Google Fonts, async non-aggregated JavaScript, remove WordPress core emoji cruft and more. As such it can improve your site's performance even when already on HTTP/2! There is extensive API available to enable you to tailor Autoptimize to each and every site's specific needs.
15
- If you consider performance important, you really should use one of the many caching plugins to do page caching. Some good candidates to complement Autoptimize that way are e.g. [KeyCDN's Cache Enabler](https://wordpress.org/plugins/cache-enabler) or [WP Super Cache](http://wordpress.org/plugins/wp-super-cache/).
16
 
17
  > <strong>Premium Support</strong><br>
18
  > We provide great [Autoptimize Pro Support and Web Performance Optimization services](https://autoptimize.com/), check out our offering on [https://autoptimize.com/](https://autoptimize.com/)!
@@ -311,6 +311,11 @@ Just [fork Autoptimize on Github](https://github.com/futtta/autoptimize) and cod
311
 
312
  == Changelog ==
313
 
 
 
 
 
 
314
  = 2.7.5 =
315
  * urgent fix for Google Fonts aggregate & preload that broke badly in 2.7.4.
316
 
5
  Requires at least: 4.9
6
  Tested up to: 5.5
7
  Requires PHP: 5.6
8
+ Stable tag: 2.7.6
9
 
10
  Autoptimize speeds up your website by optimizing JS, CSS, images (incl. lazy-load), HTML and Google Fonts, asyncing JS, removing emoji cruft and more.
11
 
12
  == Description ==
13
 
14
  Autoptimize makes optimizing your site really easy. It can aggregate, minify and cache scripts and styles, injects CSS in the page head by default but can also inline critical CSS and defer the aggregated full CSS, moves and defers scripts to the footer and minifies HTML. You can optimize and lazy-load images, optimize Google Fonts, async non-aggregated JavaScript, remove WordPress core emoji cruft and more. As such it can improve your site's performance even when already on HTTP/2! There is extensive API available to enable you to tailor Autoptimize to each and every site's specific needs.
15
+ If you consider performance important, you really should use one of the many caching plugins to do page caching. Some good candidates to complement Autoptimize that way are e.g. [Speed Booster Pack](https://wordpress.org/plugins/speed-booster-pack/), [KeyCDN's Cache Enabler](https://wordpress.org/plugins/cache-enabler) or [WP Super Cache](http://wordpress.org/plugins/wp-super-cache/).
16
 
17
  > <strong>Premium Support</strong><br>
18
  > We provide great [Autoptimize Pro Support and Web Performance Optimization services](https://autoptimize.com/), check out our offering on [https://autoptimize.com/](https://autoptimize.com/)!
311
 
312
  == Changelog ==
313
 
314
+ = 2.7.6 =
315
+ * fix for top frontend admin-bar being invisible when "inline & defer" is active.
316
+ * fix for 3rd party CSS-files not being deferred when "inline & defer" is active.
317
+ * small copy changes on Extra settings screen.
318
+
319
  = 2.7.5 =
320
  * urgent fix for Google Fonts aggregate & preload that broke badly in 2.7.4.
321