• Resolved jamminjames

    (@jamminjames)


    I can’t get the do_not_defer filter hook to work.

    I added this to my child functions file, as you recommend:

    function scripts_to_not_defer(){
    return array('jquery','jquery.flexslider-min.js?v=1.0');
    }
    add_filter('do_not_defer','scripts_to_not_defer');

    I’ve tried it with the script’s full url, with and without the version number, etc, but it still gets deferred.

    Any ideas how I could get it to work?

    https://www.ads-software.com/plugins/wp-deferred-javascripts/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Willy Bahuaud

    (@willybahuaud)

    Hello,
    Sorry for the time of reply ^^

    It’s just because do_not_defer need an array of handles ; I think jquery.flexslider-min.js?v=1.0 is not an handle…

    Since version 2.0.0, we complete the readme section about filters.

    You need to find the handle of a js script to put in the array. Put this in your functions.php temporarily it will print all script handles for scripts being enqueued on a page:

    function inspect_scripts_or_styles() {
        echo "<br />JS assets:<br />";
        global $wp_scripts;
        foreach( $wp_scripts->queue as $handle ) :
            echo $handle . '<br />';
        endforeach;
    }
    
    add_action( 'wp_print_scripts', 'inspect_scripts_or_styles' );

    Don’t lose your time with this, the upgrade to v2 broke everything. Even following their guide is useless, nothing works anymore.

    Just rollback to the last pre-2.0 version.

    Plugin Author Willy Bahuaud

    (@willybahuaud)

    Hello @jamminjames,
    Contrary to what @al_whatever said, rolling back to a previous release will do nothing…
    do_not_defer work in the same way : it take an array of scripts handles, not an array of scripts url. You can use the function proposed by @cotswoldphoto to find your script handle.

    @al_whatever, if you encounter a problem with the new release, you can open a new topic and I will help you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can't get do_not_defer to work’ is closed to new replies.