[Resolved] Jquery removal

Home Forums Support [Resolved] Jquery removal

Home Forums Support Jquery removal

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #935745
    Simon

    Hey guys,

    I would like to stop Jquery from loading. I have removed the stick navigation, is that the only setting that causes the theme to include “sticky.min.js”?

    The only other instance of jquery i have is in WPshowPost, that only loads on the home page. It uses Jquery: “jquery.matchHeight.js”

    Any idea on how to stop that?

    And lastly, does the theme load jquery if it’s not using it? I read a few posts that seem to change over time.

    #936072
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Yes, the sticky navigation option is the only reason sticky.min.js will load.

    As for the WPSP question, try this PHP:

    add_action( 'wp_print_scripts', function() {
        wp_dequeue_script( 'wpsp-matchHeight' );
    } );
    #936792
    Simon

    Perfect.

    Thanks Tommo. I think that should work but due to so many levels of caching, no idea if it actually worked πŸ™‚

    I have GP Premium, will I need to dequeue jquery on the font end manually or should it just stop loading?

    And if i should do it manually, do you have a function for that?

    Cheers,
    Simon

    #936816
    David
    Staff
    Customer Support

    Hi there,

    with the sticky navigation switched off GP will not enqueue jQuery – so not action required.

    #936820
    Simon

    Awesome!

    Thank you David.

    #936822
    David
    Staff
    Customer Support

    Glad we could be of help

    #939336
    Simon

    Hey Guys,

    So I have cleared the cache, and waited a few days for good measure. But both the matchHeight and the sticky.js files are still loading… I am at a loss for how to solve this.

    I tried turning off the WPshowpost and GPPremium plugins and the files go away immediately.

    Any ideas?

    #939629
    Simon

    Just FYI. I used a plugin called Perfmatters to force stop these files running, but i would like to get to the bottom of what is causing this to happen for me.
    Do you guys experience this on your installs?

    #939656
    Simon

    Oh, and sorry to keep bombing you guys with questions. I also noted that on the GPPremium Blog Categories it uses Jquery somewhere. Is it the infinite scroll?

    Edit: I see that it is. I decided to keep Jquery on those pages because I really like the infinite scroll.

    #939729
    Tom
    Lead Developer
    Lead Developer

    sticky.js will only load if a sticky navigation is set (main navigation or mobile header).

    Masonry and infinite scroll use jQuery (no way around this, unfortunately).

    #939753
    Simon

    Ahh there was a sticky under mobile header!!! Sorry totally had no idea about that one.

    Thanks Tom. Fixed everything… Well it seems the dequeue code i used for the matchHeight didnt work, but maybe that has to do wit the fact that it only runs on the home page.

    Thanks so much for all your help.

    #939932
    Tom
    Lead Developer
    Lead Developer

    No problem! We’ll be removing that file from WPSP soon anyways. Perfmatters is a great plugin to have πŸ™‚

    #1604177
    Erik

    Hi there,

    I would also like to dequeue the “wpsp-matchHeight” script from WP Show Posts, but the code below doesn’t work:

    add_action( 'wp_print_scripts', function() {
        wp_dequeue_script( 'wpsp-matchHeight' );
    } );

    I enqueued another script inside the same code block above just to test the block actually runs. It does, but the “wpsp-matchHeight” script doesn’t get removed.

    The question is … why doesn’t this work?

    #1604272
    Elvin
    Staff
    Customer Support

    Hi,

    You can try this instead (wp_enqueue_scripts):

    add_action( 'wp_enqueue_scripts', function() {
            wp_dequeue_style( 'wpsp-matchHeight' );
    }, 100 );

    A wise man once said:
    "Have you cleared your cache?"

    #1604310
    Erik

    Thanks for the prompt reply, Elvin πŸ™‚

    Unfortunately, that doesn’t work … but I now know why … and I have a solution … although it’s moot now. I’ll explain everything πŸ™‚

    I took a look at the wpsp_display() function in wp-show-posts.php.

    Dequeuing “wpsp-matchHeight” through wp_enqueue_scripts, wp_print_scripts, etc won’t work because those hooks have long since been executed by the time “wpsp-matchHeight” gets enqueued.

    I ran a test to display wp_script_is('wpsp-matchHeight') using the wpsp_settings and wpsp_wrapper_atts filters I spotted in wp-show-posts.php.

    These two filters run before and after the line that enqueues “wpsp-matchHeight” respectively.

    As expected, the first filter obviously doesn’t work (too early).

    But the second filter works (or any other hook that runs after “wpsp-matchHeight” gets enqueued), and that’s how/where I dequeued the redundant jQuery-dependent “wpsp-matchHeight” script.

    All of that being said, this issue is now moot because of the following (which I found after figuring things out):

    Tweak: Remove matchHeight.js

    https://wpshowposts.com/wp-show-posts-1-2-0/

    I installed version 1.2.0 and all seems to be working nicely πŸ™‚

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.