Async JavaScript - Version 1.16.06.22

Version Description

  • MOD: Remove admin message marketing
  • MOD: Moved menu item to Settings menu
  • MOD: Fixed marketing image css
  • MOD: Fixed spelling of 'JavaScript' to 'JavaScript'
Download this release

Release Info

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

Code changes from version 1.16.06.21 to 1.16.06.22

Files changed (4) hide show
  1. async-javascript.php +38 -42
  2. css/admin.css +2 -2
  3. js/admin.js +3 -3
  4. readme.txt +21 -14
async-javascript.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
  /*
4
- Plugin Name: Async Javascript
5
  Plugin URI: http://cloughit.com.au/product/async-javascript/
6
- Description: Async Javascript adds a 'async' or 'defer' attribute to scripts loaded via wp_enqueue_script
7
- Version: 1.16.06.21
8
- Author: David Clough (cloughit)
9
  Author URI: http://www.cloughit.com.au/
10
  Text Domain: async-javascript
11
  License: GNU General Public License v2 or later
@@ -23,7 +23,7 @@ add_action('admin_init','aj_admin_init');
23
  function aj_admin_init() {
24
  define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
25
  define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
26
- define( 'AJ_VERSION', '1.16.06.21' );
27
  wp_register_style(
28
  'aj_admin_styles',
29
  plugins_url('/css/admin.css',__FILE__)
@@ -50,21 +50,6 @@ function aj_admin_init() {
50
  delete_option( 'autoptimize_enabled' );
51
  }
52
  }
53
- /**
54
- * async_javascript_menu()
55
- *
56
- * register admin menu
57
- *
58
- * @param n/a
59
- * @return n/a
60
- */
61
- add_action( 'admin_notices', 'async_javascript_upgrade_notice' );
62
- function async_javascript_upgrade_notice() {
63
- $aj_upgrade_notice = get_option( 'aj_upgrade_notice' );
64
- if ( $aj_upgrade_notice != AJ_VERSION ) {
65
- echo '<div class="notice notice-warning is-dismissible aj-upgrade-notice"><p><em>Take full control with </em><strong>Async Javascript Pro.</strong> <a href="http://cloughit.com.au/product/async-javascript-pro/" target="_blank">Read more...</a></p></div>';
66
- }
67
- }
68
  /**
69
  * async_javascript_menu()
70
  *
@@ -75,7 +60,16 @@ function async_javascript_upgrade_notice() {
75
  */
76
  add_action('admin_menu','async_javascript_menu');
77
  function async_javascript_menu() {
78
- add_menu_page('Async Javascript Admin','Async Javascript','manage_options','async-javascript','async_javascript_admin');
 
 
 
 
 
 
 
 
 
79
  }
80
  /**
81
  * async_javascript_admin()
@@ -87,15 +81,15 @@ function async_javascript_menu() {
87
  */
88
  function async_javascript_admin() {
89
  // Display settings saved message if optioned updated
90
- if( isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' ) {
91
  echo '<div class="updated"><p><strong>Settings saved.</strong></p></div>';
92
- }
93
  // load settings from database
94
  ?>
95
  <div class="wrap">
96
- <h2>Async Javascript Settings</h2>
97
  <form action="options.php" method="post" name="options">
98
- <?php
99
  settings_fields( 'aj_options' );
100
  do_settings_sections( 'aj_options' );
101
  $aj_enabled = (get_option('aj_enabled') == 1) ? array(true,'checked','') : array(false,'','style="display:none;"');
@@ -106,11 +100,11 @@ function async_javascript_admin() {
106
  <table class="form-table" width="100%" cellpadding="10">
107
  <tbody>
108
  <tr>
109
- <td style="width:67%;vertical-align: top;">
110
  <table class="form-table" width="100%" cellpadding="10">
111
  <tbody>
112
- <tr><td scope="row" align="left" colspan="2"><h3>Enable Async Javascript</h3></td></tr>
113
- <tr><td scope="row" align="left" colspan="2">When you enable Async Javascript, when a script is loaded via the 'wp_enqueue_script' method, this plugin will add a 'async' or 'defer' attribute.</td></tr>
114
  <tr><td scope="row" align="left" colspan="2">This action helps to eliminate render-blocking JavaScript in above-the-fold content. This can also help to increase your pagespeed which in turn will assist in improving your page ranking.</td></tr>
115
  <tr>
116
  <td scope="row" align="left" colspan="2">
@@ -122,16 +116,16 @@ function async_javascript_admin() {
122
  </ul>
123
  </td>
124
  </tr>
125
- <tr><td scope="row" align="left" colspan="2"><strong>Note: </strong>There have been instances where enabling Async Javascript has 'broken' the javascript delivery. Should this happen to you, I highly recommend installing the <a href="https://wordpress.org/plugins/autoptimize/" target="_blank">Autoptimize</a> plugin which will combine your javascript, further enhancing pagespeed and eliminating this issue.</td></tr>
126
  <tr>
127
- <td scope="row" align="left" style="width:20%;"><label>Enable Async Javascript</label></td>
128
  <td scope="row" align="left"><input type="checkbox" name="aj_enabled" id="aj_enabled" value="1" <?php echo $aj_enabled[1]; ?> /></td>
129
  </tr>
130
  </tbody>
131
  </table>
132
  <table class="form-table aj_method" width="100%" cellpadding="10">
133
  <tbody>
134
- <tr><td scope="row" align="left" colspan="2"><h3>Async Javascript Method</h3></td></tr>
135
  <tr><td scope="row" align="left" colspan="2">Please select the method (async or defer) that you wish to enable:</td></tr>
136
  <tr>
137
  <td scope="row" align="left" style="width:20%;">Method</td>
@@ -151,9 +145,10 @@ function async_javascript_admin() {
151
  </table>
152
  <table class="form-table aj_method" width="100%" cellpadding="10">
153
  <tbody>
154
- <tr><td scope="row" align="left" colspan="2"><hr/><h3>Async Javascript For Plugins</h3></td></tr>
155
- <tr><td scope="row" align="left" colspan="2"><hr/><strong>Note: </strong>This will attempt to add the 'async' or 'defer' attribute to scripts loaded via a plugin (ie, not via 'wp_enqueue_script'). If you have a plugin that you would like added to this list please email <a href="mailto:support@cloughit.com.au">support@cloughit.com.au</a></td></tr>
156
  <?php
 
157
  if (is_plugin_active('autoptimize/autoptimize.php')) {
158
  ?>
159
  <tr><td scope="row" align="left" colspan="2"><hr/><h4>Autoptimize - <a href="https://wordpress.org/plugins/autoptimize/" target="_blank"><?php echo 'https://wordpress.org/plugins/autoptimize/'; ?></a></h4></td></tr>
@@ -162,14 +157,20 @@ function async_javascript_admin() {
162
  <td scope="row" align="left"><input type="checkbox" name="aj_autoptimize_enabled" value="1" <?php echo $aj_autoptimize_enabled; ?> /></td>
163
  </tr>
164
  <?php
 
165
  }
 
 
 
 
 
166
  ?>
167
  </tbody>
168
  </table>
169
- <?php submit_button(); ?>
170
  </td>
171
- <td style="width:33%;vertical-align: top;">
172
- <a href="http://cloughit.com.au/product/async-javascript-pro/" target="_blank"><img src="<?php echo AJ_PLUGIN_URL; ?>images/async-javascript-pro.jpg"></a>
173
  </td>
174
  </tr>
175
  </tbody>
@@ -187,7 +188,7 @@ function async_javascript_admin() {
187
  * @param string $handle The script's registered handle.
188
  * @param string $src The script's source URL.
189
  * @return string $tag Modified <script> tag
190
- *
191
  */
192
  add_filter('script_loader_tag','async_js',20,3);
193
  function async_js($tag,$handle,$src) {
@@ -230,9 +231,4 @@ function my_autoptimize_defer($defer) {
230
  }
231
  }
232
  }
233
- add_action( 'wp_ajax_async_javascript_dismiss_upgrade', 'async_javascript_dismiss_upgrade' );
234
- function async_javascript_dismiss_upgrade() {
235
- update_option( 'aj_upgrade_notice', AJ_VERSION );
236
- die();
237
- }
238
  ?>
1
  <?php
2
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
  /*
4
+ Plugin Name: Async JavaScript
5
  Plugin URI: http://cloughit.com.au/product/async-javascript/
6
+ Description: Async JavaScript adds a 'async' or 'defer' attribute to scripts loaded via wp_enqueue_script
7
+ Version: 1.16.06.22
8
+ Author: Clough I.T. Solutions
9
  Author URI: http://www.cloughit.com.au/
10
  Text Domain: async-javascript
11
  License: GNU General Public License v2 or later
23
  function aj_admin_init() {
24
  define( 'AJ_PLUGIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
25
  define( 'AJ_PLUGIN_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
26
+ define( 'AJ_VERSION', '1.16.06.22' );
27
  wp_register_style(
28
  'aj_admin_styles',
29
  plugins_url('/css/admin.css',__FILE__)
50
  delete_option( 'autoptimize_enabled' );
51
  }
52
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  /**
54
  * async_javascript_menu()
55
  *
60
  */
61
  add_action('admin_menu','async_javascript_menu');
62
  function async_javascript_menu() {
63
+ //add_menu_page('Async JavaScript Admin','Async JavaScript','manage_options','async-javascript','async_javascript_admin');
64
+ add_submenu_page(
65
+ 'options-general.php',
66
+ 'Async JavaScript Admin',
67
+ 'Async JavaScript',
68
+ 'manage_options',
69
+ 'async-javascript',
70
+ 'async_javascript_admin'
71
+ );
72
+
73
  }
74
  /**
75
  * async_javascript_admin()
81
  */
82
  function async_javascript_admin() {
83
  // Display settings saved message if optioned updated
84
+ /*if( isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true' ) {
85
  echo '<div class="updated"><p><strong>Settings saved.</strong></p></div>';
86
+ }*/
87
  // load settings from database
88
  ?>
89
  <div class="wrap">
90
+ <h2>Async JavaScript Settings</h2>
91
  <form action="options.php" method="post" name="options">
92
+ <?php
93
  settings_fields( 'aj_options' );
94
  do_settings_sections( 'aj_options' );
95
  $aj_enabled = (get_option('aj_enabled') == 1) ? array(true,'checked','') : array(false,'','style="display:none;"');
100
  <table class="form-table" width="100%" cellpadding="10">
101
  <tbody>
102
  <tr>
103
+ <td style="width:75%;vertical-align: top;">
104
  <table class="form-table" width="100%" cellpadding="10">
105
  <tbody>
106
+ <tr><td scope="row" align="left" colspan="2"><h3>Enable Async JavaScript</h3></td></tr>
107
+ <tr><td scope="row" align="left" colspan="2">When you enable Async JavaScript, when a script is loaded via the 'wp_enqueue_script' method, this plugin will add a 'async' or 'defer' attribute.</td></tr>
108
  <tr><td scope="row" align="left" colspan="2">This action helps to eliminate render-blocking JavaScript in above-the-fold content. This can also help to increase your pagespeed which in turn will assist in improving your page ranking.</td></tr>
109
  <tr>
110
  <td scope="row" align="left" colspan="2">
116
  </ul>
117
  </td>
118
  </tr>
119
+ <tr><td scope="row" align="left" colspan="2"><strong>Note: </strong>There have been instances where enabling Async JavaScript has 'broken' the javascript delivery. Should this happen to you, I highly recommend installing the <a href="https://wordpress.org/plugins/autoptimize/" target="_blank">Autoptimize</a> plugin which will combine your javascript, further enhancing pagespeed and eliminating this issue.</td></tr>
120
  <tr>
121
+ <td scope="row" align="left" style="width:20%;"><label>Enable Async JavaScript</label></td>
122
  <td scope="row" align="left"><input type="checkbox" name="aj_enabled" id="aj_enabled" value="1" <?php echo $aj_enabled[1]; ?> /></td>
123
  </tr>
124
  </tbody>
125
  </table>
126
  <table class="form-table aj_method" width="100%" cellpadding="10">
127
  <tbody>
128
+ <tr><td scope="row" align="left" colspan="2"><h3>Async JavaScript Method</h3></td></tr>
129
  <tr><td scope="row" align="left" colspan="2">Please select the method (async or defer) that you wish to enable:</td></tr>
130
  <tr>
131
  <td scope="row" align="left" style="width:20%;">Method</td>
145
  </table>
146
  <table class="form-table aj_method" width="100%" cellpadding="10">
147
  <tbody>
148
+ <tr><td scope="row" align="left" colspan="2"><hr/><h3>Async JavaScript For Plugins</h3></td></tr>
149
+ <tr><td scope="row" align="left" colspan="2"><hr/><strong>Note: </strong>This will attempt to add the 'async' or 'defer' attribute to scripts loaded via a plugin (ie, not via 'wp_enqueue_script'). If you have a plugin that you would like added to this list please lodge a ticket at <a href="http://cloughit.com.au/support/">http://cloughit.com.au/support/</a></td></tr>
150
  <?php
151
+ $plugins = false;
152
  if (is_plugin_active('autoptimize/autoptimize.php')) {
153
  ?>
154
  <tr><td scope="row" align="left" colspan="2"><hr/><h4>Autoptimize - <a href="https://wordpress.org/plugins/autoptimize/" target="_blank"><?php echo 'https://wordpress.org/plugins/autoptimize/'; ?></a></h4></td></tr>
157
  <td scope="row" align="left"><input type="checkbox" name="aj_autoptimize_enabled" value="1" <?php echo $aj_autoptimize_enabled; ?> /></td>
158
  </tr>
159
  <?php
160
+ $plugins = true;
161
  }
162
+ if ( !$plugins ) {
163
+ ?>
164
+ <tr><td scope="row" align="left" colspan="2">No supported plugins installed or activated.</td></tr>
165
+ <?php
166
+ }
167
  ?>
168
  </tbody>
169
  </table>
170
+ <?php submit_button(); ?>
171
  </td>
172
+ <td style="width:25%;vertical-align: top;">
173
+ <a href="http://cloughit.com.au/product/async-javascript-pro/" target="_blank"><img src="<?php echo AJ_PLUGIN_URL; ?>images/async-javascript-pro.jpg" style="max-width:100%;"></a>
174
  </td>
175
  </tr>
176
  </tbody>
188
  * @param string $handle The script's registered handle.
189
  * @param string $src The script's source URL.
190
  * @return string $tag Modified <script> tag
191
+ *
192
  */
193
  add_filter('script_loader_tag','async_js',20,3);
194
  function async_js($tag,$handle,$src) {
231
  }
232
  }
233
  }
 
 
 
 
 
234
  ?>
css/admin.css CHANGED
@@ -1,7 +1,7 @@
1
  /*
2
- Plugin Name: Async Javascript
3
  Plugin URI: http://www.cloughit.com.au/wordpress/plugins/async-javascript-wordpress-plugin/
4
- Description: Async Javascript adds a 'async' or 'defer' attribute to scripts loaded via wp_enqueue_script
5
  Version: 1.14.12.11
6
  Author: David Clough (cloughit)
7
  Author URI: http://www.cloughit.com.au/
1
  /*
2
+ Plugin Name: Async JavaScript
3
  Plugin URI: http://www.cloughit.com.au/wordpress/plugins/async-javascript-wordpress-plugin/
4
+ Description: Async JavaScript adds a 'async' or 'defer' attribute to scripts loaded via wp_enqueue_script
5
  Version: 1.14.12.11
6
  Author: David Clough (cloughit)
7
  Author URI: http://www.cloughit.com.au/
js/admin.js CHANGED
@@ -1,7 +1,7 @@
1
  /*
2
- Plugin Name: Async Javascript
3
  Plugin URI: http://www.cloughit.com.au/wordpress/plugins/async-javascript-wordpress-plugin/
4
- Description: Async Javascript adds a 'async' or 'defer' attribute to scripts loaded via wp_enqueue_script
5
  Version: 1.14.12.11
6
  Author: David Clough (cloughit)
7
  Author URI: http://www.cloughit.com.au/
@@ -35,7 +35,7 @@ jQuery(document).ready(function() {
35
  jQuery(document).on('click','#aj_enabled',function() {
36
  isChecked();
37
  });
38
-
39
  jQuery(document).on('click','.aj-upgrade-notice',function() {
40
  jQuery.ajax({
41
  url: aj.ajaxurl,
1
  /*
2
+ Plugin Name: Async JavaScript
3
  Plugin URI: http://www.cloughit.com.au/wordpress/plugins/async-javascript-wordpress-plugin/
4
+ Description: Async JavaScript adds a 'async' or 'defer' attribute to scripts loaded via wp_enqueue_script
5
  Version: 1.14.12.11
6
  Author: David Clough (cloughit)
7
  Author URI: http://www.cloughit.com.au/
35
  jQuery(document).on('click','#aj_enabled',function() {
36
  isChecked();
37
  });
38
+
39
  jQuery(document).on('click','.aj-upgrade-notice',function() {
40
  jQuery.ajax({
41
  url: aj.ajaxurl,
readme.txt CHANGED
@@ -1,24 +1,24 @@
1
- === Async Javascript ===
2
  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.5.2
7
- Stable tag: 1.16.06.21
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Async Javascript adds a 'async' attribute to scripts loaded via wp_enqueue_script
12
 
13
  == Description ==
14
 
15
- Eliminate Render-blocking Javascript in above-the-fold content with Async Javascript.
16
 
17
- Render-blocking Javascript prevents above-the-fold content on your page from being rendered until the javascript has finished loading. This can impact on your page speed and ultimately your ranking within search engines. It can also impact your users experience.
18
 
19
- Async Javascript adds a 'async' or 'defer' attribute to all scripts loaded by the WordPress wp_enqueue_script function. This 'async' or 'defer' attribute forces the javascript to be loaded asynchronously or deferred, therefore speeding up page delivery.
20
 
21
- <em>Take full control with </em><strong>Async Javascript Pro</strong>
22
 
23
  * Selective 'async'
24
  * Selective 'defer'
@@ -33,7 +33,7 @@ Just install from your WordPress "Plugins | Add New" screen and all will be well
33
 
34
  1. Upload the zip-file and unzip it in the /wp-content/plugins/ directory
35
  2. Activate the plugin through the 'Plugins' menu in WordPress
36
- 3. Go to `Async Javascript` menu to load setings page
37
 
38
  == Frequently Asked Questions ==
39
 
@@ -54,22 +54,29 @@ Please lodge a support request at https://wordpress.org/support/plugin/async-jav
54
  = What information should I include when requesting support =
55
 
56
  * A description of the problem, including screenshots and information from your browser's Error/ debug console
57
- * URL of your blog (you can turn Async Javascript off, but should be willing to turn it briefly on to have the error visible)
58
- * your Async Javascript settings (including a description of changes you made to the configuration to try to troubleshoot yourself)
59
  * the Theme used (including the Theme's download link)
60
  * optionally plugins used (if you suspect one or more plugins are raising havoc)
61
 
62
- = I want out, how should I remove Async Javascript? =
63
 
64
  * Disable the plugin
65
  * Delete the plugin
66
 
67
  == Screenshots ==
68
 
69
- 1. this screen shot description corresponds to async-javascript-screenshot1.jpg and shows the admin page for Async Javascript
70
 
71
  == Changelog ==
72
 
 
 
 
 
 
 
 
73
  = 1.16.06.21 =
74
 
75
  * MOD: converted from 'clean_url' to 'script_loader_tag' filter
@@ -81,7 +88,7 @@ Please lodge a support request at https://wordpress.org/support/plugin/async-jav
81
  = 1.16.03.13 =
82
 
83
  * FIX: Fixed autoptomize settings
84
- * FIX: Removed redundant settings
85
 
86
  = 1.16.03.12 =
87
 
@@ -97,7 +104,7 @@ Please lodge a support request at https://wordpress.org/support/plugin/async-jav
97
 
98
  = 1.16.02.17 =
99
 
100
- * NEW: Added information for Async Javascript Pro
101
 
102
  = 1.15.02.23.1 =
103
 
1
+ === Async JavaScript ===
2
  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.5.2
7
+ Stable tag: 1.16.06.22
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Async JavaScript adds a 'async' attribute to scripts loaded via wp_enqueue_script
12
 
13
  == Description ==
14
 
15
+ Eliminate Render-blocking JavaScript in above-the-fold content with Async JavaScript.
16
 
17
+ Render-blocking JavaScript prevents above-the-fold content on your page from being rendered until the javascript has finished loading. This can impact on your page speed and ultimately your ranking within search engines. It can also impact your users experience.
18
 
19
+ Async JavaScript adds a 'async' or 'defer' attribute to all scripts loaded by the WordPress wp_enqueue_script function. This 'async' or 'defer' attribute forces the javascript to be loaded asynchronously or deferred, therefore speeding up page delivery.
20
 
21
+ <em>Take full control with </em><strong>Async JavaScript Pro</strong>
22
 
23
  * Selective 'async'
24
  * Selective 'defer'
33
 
34
  1. Upload the zip-file and unzip it in the /wp-content/plugins/ directory
35
  2. Activate the plugin through the 'Plugins' menu in WordPress
36
+ 3. Go to `Async JavaScript` menu to load setings page
37
 
38
  == Frequently Asked Questions ==
39
 
54
  = What information should I include when requesting support =
55
 
56
  * A description of the problem, including screenshots and information from your browser's Error/ debug console
57
+ * URL of your blog (you can turn Async JavaScript off, but should be willing to turn it briefly on to have the error visible)
58
+ * your Async JavaScript settings (including a description of changes you made to the configuration to try to troubleshoot yourself)
59
  * the Theme used (including the Theme's download link)
60
  * optionally plugins used (if you suspect one or more plugins are raising havoc)
61
 
62
+ = I want out, how should I remove Async JavaScript? =
63
 
64
  * Disable the plugin
65
  * Delete the plugin
66
 
67
  == Screenshots ==
68
 
69
+ 1. this screen shot description corresponds to async-javascript-screenshot1.jpg and shows the admin page for Async JavaScript
70
 
71
  == Changelog ==
72
 
73
+ = 1.16.06.22 =
74
+
75
+ * MOD: Remove admin message marketing
76
+ * MOD: Moved menu item to Settings menu
77
+ * MOD: Fixed marketing image css
78
+ * MOD: Fixed spelling of 'JavaScript' to 'JavaScript'
79
+
80
  = 1.16.06.21 =
81
 
82
  * MOD: converted from 'clean_url' to 'script_loader_tag' filter
88
  = 1.16.03.13 =
89
 
90
  * FIX: Fixed autoptomize settings
91
+ * FIX: Removed redundant settings
92
 
93
  = 1.16.03.12 =
94
 
104
 
105
  = 1.16.02.17 =
106
 
107
+ * NEW: Added information for Async JavaScript Pro
108
 
109
  = 1.15.02.23.1 =
110