Changeset 2048422
- Timestamp:
- 03/11/2019 03:54:55 PM (7 years ago)
- Location:
- inline-javascript-in-head/trunk
- Files:
-
- 2 edited
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
inline-javascript-in-head/trunk/plugin.php
r2048245 r2048422 3 3 /** 4 4 * Plugin Name: Inline JavaScript in Head 5 * Description: Removes given local enqueued script handles and places their contents into the head. Useful for small scripts with a size lower than ~500 Bytes to boost site performance. Caution: Use with care and sparingly!6 * Version: 1.1 5 * Description: Boosts performance of critical short JavaScripts by placing their content directly into the HTML head. 6 * Version: 1.1.1 7 7 * Author: Palasthotel <rezeption@palasthotel.de> (Kim Meyer) 8 8 * Author URI: https://palasthotel.de -
inline-javascript-in-head/trunk/readme.txt
r2048245 r2048422 2 2 Contributors: palasthotel, greatestview 3 3 Donate link: https://palasthotel.de/ 4 Tags: javascript, inline, head, performance4 Tags: javascript, scripts, enqueue, inline, head, performance, filter, hook 5 5 Requires at least: 4.0 6 6 Tested up to: 5.1 7 Stable tag: 1.1 7 Stable tag: 1.1.1 8 Requires PHP: 5.4 8 9 License: GNU General Public License v3 9 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 11 11 Removes given local enqueued script handles and places their content into the head. Useful for small scripts with a size lower than ~500 Bytes to boost site performance. Caution: Use with care and sparingly! 12 Boosts performance of critical short JavaScripts by placing their content directly into the HTML head. 12 13 13 14 == Description == 14 15 In some cases you cannot wait for a JavaScript file to load, even if it is placed early in the `<head>` section of your template. You can benefit from better performance, if you place the JavaScript code directly inside a `<script>` tag into the header. This is where this plugin comes in: It provides a filter `inline_javascript_in_head_handles`, which takes JavaScript handles, dequeues those scripts and echos their code content inline into the head section instead of linking them via a script tag. 15 16 16 Please beware that placing lots of JavaScript code inline in the `<head>` section can be critical . First you lose caching benefits and second the generaldocument size can increase easily. A general rule of thumb is that you should only consider JavaScript files for inline placement, which are critical and which have a file size lower than ~500 Bytes.17 Please beware that placing lots of JavaScript code inline in the `<head>` section can be critical! First you lose caching benefits and second the document size can increase easily. A general rule of thumb is that you should only consider JavaScript files for inline placement, which are critical and which have a file size lower than ~500 Bytes. 17 18 18 19 = Example = 19 20 20 ` ``21 ` 21 22 add_action( 'wp_enqueue_scripts', 'my_scripts' ); 22 23 function my_scripts() { … … 34 35 return array_merge( $handles, $scripts ); 35 36 } 36 ` ``37 ` 37 38 38 39 … … 45 46 == Changelog == 46 47 48 = 1.1.1 = 49 * readme.txt update 50 47 51 = 1.1 = 48 52 * Added filter `inline_javascript_in_head_wrap_try_catch`, which can add add a try catch wrapper around the JavaScript code.
Note: See TracChangeset
for help on using the changeset viewer.