Support » Plugin: Dave's WordPress Live Search » Move scripts to wp_footer();

  • Resolved rtvenge

    (@rtvenge)


    Hello,

    Thanks for building this plugin. It works really well!

    I’m trying to get all renderblocking scripts out of the <head> per Google PageSpeed Insights. Is there a chance we could set the $in_footer param to true on the script enqueues? I just added true to the 6 enqueue functions in class-daves-wordpress-live-search.php:

    if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
      wp_enqueue_script( 'daves-wordpress-live-search', plugin_dir_url( __FILE__ ) . 'js/daves-wordpress-live-search.js', array( 'jquery' ), null, true );
      wp_enqueue_script( 'excanvas', plugin_dir_url( __FILE__ ) . 'js/excanvas.js', 'jquery', null, true );
      wp_enqueue_script( 'spinners', plugin_dir_url( __FILE__ ) . 'js/spinners.js', 'explorercanvas', null, true );
    }
    else {
      wp_enqueue_script( 'daves-wordpress-live-search', plugin_dir_url( __FILE__ ) . 'js/daves-wordpress-live-search.min.js', array( 'jquery' ), null, true );
      wp_enqueue_script( 'excanvas', plugin_dir_url( __FILE__ ) . 'js/excanvas.compiled.js', 'jquery', null, true );
      wp_enqueue_script( 'spinners', plugin_dir_url( __FILE__ ) . 'js/spinners.min.js', 'explorercanvas', null, true );
    }

    I haven’t done extensive testing on this, but let me know if you want me to. You have the dependencies set correctly, so if jquery is set in the header, it should still work correctly.

    Thanks!

    https://wordpress.org/plugins/daves-wordpress-live-search/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Dana Ross

    (@csixty4)

    That should work fine, and that’s what the new version I’m working on does.

    Thread Starter rtvenge

    (@rtvenge)

    Thanks much for getting this in the next version!

    Thread Starter rtvenge

    (@rtvenge)

    I was just checking up on this. I am running the latest version (4.3) and it looks like this didn’t make it in. I tried coming up with a fix myself, but it seems that underscore.js really wants jquery and jquery-migrate in the <head>. 🙁

    Any ideas?

    thanks!

    Plugin Author Dana Ross

    (@csixty4)

    That shouldn’t be the case, but I’ve run into weird dependency issues like that before too. In the “next generation” version of DWLS, I’m setting the $in_footer flag and my code works fine. I might put out a new version of DWLS that sets that flag just for a little extra performance if it got overlooked in the last update. But I agree it would be great if everything could be in the footer or even async. I’m just not sure WordPress is ready to run like that yet.

    Thread Starter rtvenge

    (@rtvenge)

    Thanks Dave! I’ll keep an eye out for the new version.

    Yeah, I’d love to see WordPress get better at this kind of stuff. It can be a lot trickier to implement than it looks on the surface. 🙂

    Let me know if you need any help with troubleshooting or anything. I’d love to help!

    Plugin Author Dana Ross

    (@csixty4)

    Took a while to get to it, but this is done.

    Thread Starter rtvenge

    (@rtvenge)

    Thanks a lot, Dave! I know these things seem easy on the surface but become difficult quickly.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Move scripts to wp_footer();’ is closed to new replies.