Async JavaScript - Version 1.15.02.23

Version Description

Download this release

Release Info

Developer cloughit
Plugin Icon 128x128 Async JavaScript
Version 1.15.02.23
Comparing to
See all releases

Code changes from version 1.14.12.19 to 1.15.02.23

Files changed (2) hide show
  1. async-javascript.php +20 -2
  2. readme.txt +6 -2
async-javascript.php CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
  Plugin Name: Async Javascript
5
  Plugin URI: http://www.cloughit.com.au/wordpress/plugins/async-javascript-wordpress-plugin/
6
  Description: Async Javascript adds a 'async' or 'defer' attribute to scripts loaded via wp_enqueue_script
7
- Version: 1.14.12.19
8
  Author: David Clough (cloughit)
9
  Author URI: http://www.cloughit.com.au/
10
  Text Domain: async-javascript
@@ -69,6 +69,7 @@ function async_javascript_admin() {
69
  // load settings from database
70
  $aj_enabled = (get_option('aj_enabled') == 1) ? array(true,'checked','') : array(false,'','style="display:none;"');
71
  $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async';
 
72
  $autoptimize_enabled = (get_option('autoptimize_enabled') == 1) ? 'checked' : '';
73
  ?>
74
  <div class="wrap">
@@ -107,6 +108,16 @@ function async_javascript_admin() {
107
  </tr>
108
  </tbody>
109
  </table>
 
 
 
 
 
 
 
 
 
 
110
  <table class="form-table aj_method" width="100%" cellpadding="10">
111
  <tbody>
112
  <tr><td scope="row" align="left" colspan="2"><hr/><h3>Async Javascript For Plugins</h3></td></tr>
@@ -125,7 +136,7 @@ function async_javascript_admin() {
125
  </tbody>
126
  </table>
127
  <input type="hidden" name="action" value="update" />
128
- <input type="hidden" name="page_options" value="aj_enabled,aj_method,autoptimize_enabled" />
129
  <input type="submit" name="Submit" value="Update" />
130
  </form>
131
  </div>
@@ -145,10 +156,17 @@ add_filter('clean_url','async_js',11);
145
  function async_js($url) {
146
  $aj_enabled = (get_option('aj_enabled') == 1) ? true : false;
147
  $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async';
 
 
148
  if (false !== $aj_enabled && false === is_admin()) {
149
  if (false === strpos($url,'.js')) {
150
  return $url;
151
  }
 
 
 
 
 
152
  return $url . "' " . $aj_method . "='" . $aj_method;
153
  }
154
  return $url;
4
  Plugin Name: Async Javascript
5
  Plugin URI: http://www.cloughit.com.au/wordpress/plugins/async-javascript-wordpress-plugin/
6
  Description: Async Javascript adds a 'async' or 'defer' attribute to scripts loaded via wp_enqueue_script
7
+ Version: 1.15.02.23
8
  Author: David Clough (cloughit)
9
  Author URI: http://www.cloughit.com.au/
10
  Text Domain: async-javascript
69
  // load settings from database
70
  $aj_enabled = (get_option('aj_enabled') == 1) ? array(true,'checked','') : array(false,'','style="display:none;"');
71
  $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async';
72
+ $aj_exclusions = get_option('aj_exclusions');
73
  $autoptimize_enabled = (get_option('autoptimize_enabled') == 1) ? 'checked' : '';
74
  ?>
75
  <div class="wrap">
108
  </tr>
109
  </tbody>
110
  </table>
111
+ <table class="form-table" width="100%" cellpadding="10">
112
+ <tbody>
113
+ <tr><td scope="row" align="left" colspan="2"><hr/><h3>Script Exclusion</h3></td></tr>
114
+ <tr><td scope="row" align="left" colspan="2"><hr/>Please list any scripts which you would like excluded from being Async/Defered during page load. (comma seperated list eg: jquery.js,jquery-ui.js)</td></tr>
115
+ <tr>
116
+ <td scope="row" align="left" style="width:20%;">Exclusions</td>
117
+ <td scope="row" align="left"><textarea name="aj_exclusions" style="width:95%;"><?php echo $aj_exclusions; ?></textarea></td>
118
+ </tr>
119
+ </tbody>
120
+ </table>
121
  <table class="form-table aj_method" width="100%" cellpadding="10">
122
  <tbody>
123
  <tr><td scope="row" align="left" colspan="2"><hr/><h3>Async Javascript For Plugins</h3></td></tr>
136
  </tbody>
137
  </table>
138
  <input type="hidden" name="action" value="update" />
139
+ <input type="hidden" name="page_options" value="aj_enabled,aj_method,autoptimize_enabled,aj_exclusions" />
140
  <input type="submit" name="Submit" value="Update" />
141
  </form>
142
  </div>
156
  function async_js($url) {
157
  $aj_enabled = (get_option('aj_enabled') == 1) ? true : false;
158
  $aj_method = (get_option('aj_method') != 'async') ? 'defer' : 'async';
159
+ $aj_exclusions = get_option('aj_exclusions');
160
+ $array_exclusions = explode(',',$aj_exclusions);
161
  if (false !== $aj_enabled && false === is_admin()) {
162
  if (false === strpos($url,'.js')) {
163
  return $url;
164
  }
165
+ foreach ($array_exclusions as $exclusion) {
166
+ if (false !== strpos(strtolower($url),strtolower($exclusion))) {
167
+ return $url;
168
+ }
169
+ }
170
  return $url . "' " . $aj_method . "='" . $aj_method;
171
  }
172
  return $url;
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: (cloughit)
3
  Donate link: http://www.cloughit.com.au/donate/ (coming soon)
4
  Tags: async,javascript,google,pagespeed,js,speed,performance,boost,render,blocking,above-the-fold
5
  Requires at least: 2.8
6
- Tested up to: 4.1
7
- Stable tag: 1.14.12.19
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -60,6 +60,10 @@ Contact David Clough @ Clough I.T. Solutions - support@cloughit.com.au
60
 
61
  == Changelog ==
62
 
 
 
 
 
63
  = 1.14.12.19
64
  * Tested for Wordpress v4.1
65
 
3
  Donate link: http://www.cloughit.com.au/donate/ (coming soon)
4
  Tags: async,javascript,google,pagespeed,js,speed,performance,boost,render,blocking,above-the-fold
5
  Requires at least: 2.8
6
+ Tested up to: 4.1.1
7
+ Stable tag: 1.15.02.23
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
60
 
61
  == Changelog ==
62
 
63
+ = 1.15.02.23
64
+ * Tested for WordPress v4.1.1
65
+ * Added ability to provide a comma seperated list of scripts to be excluded from async/defer (thanks to Nico Ryba for this suggestion)
66
+
67
  = 1.14.12.19
68
  * Tested for Wordpress v4.1
69