Async JavaScript - Version 2.21.08.31

Version Description

  • workaround for issues with some inline JS getting asynced (hat tip to WP Bullet's Mike)
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 Async JavaScript
Version 2.21.08.31
Comparing to
See all releases

Code changes from version 2.21.06.29 to 2.21.08.31

async-javascript.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Async JavaScript
4
  * Plugin URI: https://autoptimize.com/
5
  * Description: Async JavaScript gives you full control of which scripts to add a 'async' or 'defer' attribute to or to exclude to help increase the performance of your WordPress website
6
- * Version: 2.21.06.29
7
  * Author: Frank Goossens (futtta)
8
  * Author URI: https://autoptimize.com/
9
  * Text Domain: async-javascript
3
  * Plugin Name: Async JavaScript
4
  * Plugin URI: https://autoptimize.com/
5
  * Description: Async JavaScript gives you full control of which scripts to add a 'async' or 'defer' attribute to or to exclude to help increase the performance of your WordPress website
6
+ * Version: 2.21.08.31
7
  * Author: Frank Goossens (futtta)
8
  * Author URI: https://autoptimize.com/
9
  * Text Domain: async-javascript
asyncjsAllAjax.php CHANGED
@@ -381,18 +381,18 @@ if ( ! isset( $_POST['sub_action'] ) || ! current_user_can( 'manage_options' ) |
381
  }
382
  break;
383
  case 'aj_save_settings':
384
- $aj_enabled = sanitize_text_field( $_POST['aj_enabled'] );
385
- $aj_enabled_logged = sanitize_text_field( $_POST['aj_enabled_logged'] );
386
- $aj_enabled_shop = sanitize_text_field( $_POST['aj_enabled_shop'] );
387
- $aj_method = sanitize_text_field( $_POST['aj_method'] );
388
- $aj_jquery = sanitize_text_field( $_POST['aj_jquery'] );
389
- $aj_async = sanitize_text_field( $_POST['aj_async'] );
390
- $aj_defer = sanitize_text_field( $_POST['aj_defer'] );
391
- $aj_exclusions = sanitize_text_field( $_POST['aj_exclusions'] );
392
- $aj_plugin_exclusions = $_POST['aj_plugin_exclusions'];
393
- $aj_theme_exclusions = $_POST['aj_theme_exclusions'];
394
- $aj_autoptimize_enabled = sanitize_text_field( $_POST['aj_autoptimize_enabled'] );
395
- $aj_autoptimize_method = sanitize_text_field( $_POST['aj_autoptimize_method'] );
396
  update_option( 'aj_enabled', $aj_enabled );
397
  update_option( 'aj_enabled_logged', $aj_enabled_logged );
398
  update_option( 'aj_enabled_shop', $aj_enabled_shop );
381
  }
382
  break;
383
  case 'aj_save_settings':
384
+ $aj_enabled = ( empty($_POST['aj_enabled'] ) ) ? '' : sanitize_text_field( $_POST['aj_enabled'] );
385
+ $aj_enabled_logged = ( empty($_POST['aj_enabled_logged'] ) ) ? '' : sanitize_text_field( $_POST['aj_enabled_logged'] );
386
+ $aj_enabled_shop = ( empty($_POST['aj_enabled_shop'] ) ) ? '' : sanitize_text_field( $_POST['aj_enabled_shop'] );
387
+ $aj_method = ( empty($_POST['aj_method'] ) ) ? '' : sanitize_text_field( $_POST['aj_method'] );
388
+ $aj_jquery =( empty($_POST['aj_jquery'] ) ) ? '' : sanitize_text_field( $_POST['aj_jquery'] );
389
+ $aj_async = ( empty($_POST['aj_async'] ) ) ? '' : sanitize_text_field( $_POST['aj_async'] );
390
+ $aj_defer = ( empty($_POST['aj_defer'] ) ) ? '' : sanitize_text_field( $_POST['aj_defer'] );
391
+ $aj_exclusions = ( empty($_POST['aj_exclusions'] ) ) ? '' : sanitize_text_field( $_POST['aj_exclusions'] );
392
+ $aj_plugin_exclusions = ( empty($_POST['aj_plugin_exclusions'] ) ) ? '' : array_map( 'sanitize_text_field', $_POST['aj_plugin_exclusions'] );
393
+ $aj_theme_exclusions = ( empty($_POST['aj_theme_exclusions'] ) ) ? '' : array_map( 'sanitize_text_field', $_POST['aj_theme_exclusions'] ) ;
394
+ $aj_autoptimize_enabled = ( empty($_POST['aj_autoptimize_enabled'] ) ) ? '' : sanitize_text_field( $_POST['aj_autoptimize_enabled'] );
395
+ $aj_autoptimize_method = ( empty($_POST['aj_autoptimize_method'] ) ) ? '' : sanitize_text_field( $_POST['aj_autoptimize_method'] );
396
  update_option( 'aj_enabled', $aj_enabled );
397
  update_option( 'aj_enabled_logged', $aj_enabled_logged );
398
  update_option( 'aj_enabled_shop', $aj_enabled_shop );
asyncjsBackendClass.php CHANGED
@@ -17,7 +17,7 @@ class AsyncJavaScriptBackend {
17
  define( 'AJ_ADMIN_URL', trailingslashit( admin_url() ) );
18
  define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
19
  define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
20
- define( 'AJ_VERSION', '2.21.06.29' );
21
  define( 'AJ_UA', 'Async JavaScript/' . AJ_VERSION . ' (+https://autoptimize.com/)' );
22
  add_filter( 'plugin_action_links_'.plugin_basename( 'async-javascript/async-javascript.php' ), array( $this, 'setmeta' ), 10, 2 );
23
  add_action( 'plugins_loaded', array( $this, 'aj_admin_init' ) );
17
  define( 'AJ_ADMIN_URL', trailingslashit( admin_url() ) );
18
  define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
19
  define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
20
+ define( 'AJ_VERSION', '2.21.08.31' );
21
  define( 'AJ_UA', 'Async JavaScript/' . AJ_VERSION . ' (+https://autoptimize.com/)' );
22
  add_filter( 'plugin_action_links_'.plugin_basename( 'async-javascript/async-javascript.php' ), array( $this, 'setmeta' ), 10, 2 );
23
  add_action( 'plugins_loaded', array( $this, 'aj_admin_init' ) );
asyncjsFrontendClass.php CHANGED
@@ -69,9 +69,12 @@ class AsyncJavaScriptFrontend {
69
  $aj_theme_exclusions = get_option( 'aj_theme_exclusions', array() );
70
  }
71
 
72
- // hard exclude "document.write", which e.g. WordPress core uses to add polyfills,
73
  // but we _really_ should hide all inline JS from AsyncJS in a future release.
74
  $array_exclusions[] = 'document.write';
 
 
 
75
 
76
  if ( false !== $aj_enabled && false !== $this->aj_shop() && false !== $this->aj_logged() && false === is_admin() && false === $this->aj_is_amp() && false === $this->aj_noptimize() ) {
77
  if ( is_array( $aj_plugin_exclusions ) && !empty( $aj_plugin_exclusions ) ) {
69
  $aj_theme_exclusions = get_option( 'aj_theme_exclusions', array() );
70
  }
71
 
72
+ // hard exclude some typical inline JS functions that might break by being asynced but should not
73
  // but we _really_ should hide all inline JS from AsyncJS in a future release.
74
  $array_exclusions[] = 'document.write';
75
+ $array_exclusions[] = 'createElement';
76
+ $array_exclusions[] = 'getElementsByTagName';
77
+ $array_exclusions[] = 'appendChild';
78
 
79
  if ( false !== $aj_enabled && false !== $this->aj_shop() && false !== $this->aj_logged() && false === is_admin() && false === $this->aj_is_amp() && false === $this->aj_noptimize() ) {
80
  if ( is_array( $aj_plugin_exclusions ) && !empty( $aj_plugin_exclusions ) ) {
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: (cloughit), optimizingmatters, futtta, wormeyman
3
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
4
  Tags: async, javascript, pagespeed, performance, render blocking
5
  Requires at least: 4.6
6
- Tested up to: 5.8
7
- Stable tag: 2.21.06.29
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -57,6 +57,10 @@ We recommend using the awesome <a href="https://wordpress.org/plugins/autoptimiz
57
 
58
  == Changelog ==
59
 
 
 
 
 
60
  = 2.21.06.29 =
61
 
62
  * fix for an authenticated stored XSS vulnerability, credits to m0ze for discovering
3
  Donate link: http://blog.futtta.be/2013/10/21/do-not-donate-to-me/
4
  Tags: async, javascript, pagespeed, performance, render blocking
5
  Requires at least: 4.6
6
+ Tested up to: 6.0
7
+ Stable tag: 2.21.08.31
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
57
 
58
  == Changelog ==
59
 
60
+ = 2.21.08.31 =
61
+
62
+ * workaround for issues with some inline JS getting asynced (hat tip to WP Bullet's Mike)
63
+
64
  = 2.21.06.29 =
65
 
66
  * fix for an authenticated stored XSS vulnerability, credits to m0ze for discovering