Plugin Directory

Changeset 2294616


Ignore:
Timestamp:
04/29/2020 08:04:22 PM (6 years ago)
Author:
palasthotel
Message:

Release v1.2.0

Location:
inline-javascript-in-head/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inline-javascript-in-head/trunk/plugin.php

    r2048426 r2294616  
    44 * Plugin Name: Inline JavaScript in Head
    55 * Description: Boosts performance of critical short JavaScripts by placing their content directly into the HTML head.
    6  * Version: 1.1.2
     6 * Version: 1.2.0
    77 * Author: Palasthotel <rezeption@palasthotel.de> (Kim Meyer)
    88 * Author URI: https://palasthotel.de
     
    3939     */
    4040    private function __construct() {
    41 
    42         /**
    43          * Base paths
    44          */
    45         $this->dir = plugin_dir_path( __FILE__ );
    46         $this->url = plugin_dir_url( __FILE__ );
    47 
    48         add_action( 'wp_enqueue_scripts', array( $this, 'dequeue_script_for_inlining' ), 20 );
    4941        add_action( 'wp_print_scripts', array( $this, 'inline_scripts_in_head' ), 0 );
    50     }
    51 
    52     private function get_script_handles_to_be_inlined() {
    53         return apply_filters( Plugin::FILTER_HANDLES, array() );
    54     }
    55 
    56     /**
    57      * First remove JavaScript files with given handle.
    58      */
    59     public function dequeue_script_for_inlining() {
    60         $handles = $this->get_script_handles_to_be_inlined();
    61         foreach ( $handles as $handle ) {
    62             wp_dequeue_script( $handle );
    63         }
    6442    }
    6543
     
    6947     */
    7048    public function inline_scripts_in_head() {
    71         $handles = $this->get_script_handles_to_be_inlined();
     49        $handles = apply_filters( Plugin::FILTER_HANDLES, array() );
    7250        if ( empty( $handles ) ) {
    7351            return;
     
    9270            }
    9371
     72            // Now it’s safe to dequeue the JavaScript file.
     73            $scripts->registered[ $handle ]->src = '';
     74
    9475            if ( apply_filters( Plugin::FILTER_WRAP_TRY_CATCH, false, $handle ) === true ) {
    9576                $script_content = "try{" . $script_content . "}catch(e){}";
  • inline-javascript-in-head/trunk/readme.txt

    r2048426 r2294616  
    44Tags: javascript, scripts, enqueue, inline, head, performance, filter, hook
    55Requires at least: 4.0
    6 Tested up to: 5.1
    7 Stable tag: 1.1.2
     6Tested up to: 5.4
     7Stable tag: 1.2.0
    88Requires PHP: 5.4
    99License: GNU General Public License v3
     
    1313
    1414== Description ==
     15**CAUTION**: This plugin is now deprecated! The successor plugin is [Embed JavaScript File Content](https://wordpress.org/plugins/embed-javascript-file-content/). The new plugin is rebuild from scratch and more rock solid: It respects order and position of scripts and extra scripts added via `wp_add_inline_script` or `wp_localize_script` don’t get lost. Give it a try!
     16
    1517In 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.
    1618
     
    4648== Changelog ==
    4749
     50= 1.2.0 =
     51* CAUTION: Last update! This plugin is now deprecated (see description section)
     52* Bugfix: Some scripts could have gotten lost under certain conditions.
     53
    4854= 1.1.2 =
    4955* readme.txt code appearance screwed up, now hopefully fixed.
Note: See TracChangeset for help on using the changeset viewer.