- This topic has 15 replies, 2 voices, and was last updated 3 years, 3 months ago by Elvin.
-
AuthorPosts
-
June 20, 2019 at 6:20 am #935745Simon
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.
June 20, 2019 at 8:42 am #936072TomLead DeveloperLead DeveloperHi 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' ); } );
June 21, 2019 at 4:59 am #936792SimonPerfect.
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,
SimonJune 21, 2019 at 5:24 am #936816DavidStaffCustomer SupportHi there,
with the sticky navigation switched off GP will not enqueue jQuery – so not action required.
June 21, 2019 at 5:28 am #936820SimonAwesome!
Thank you David.
June 21, 2019 at 5:34 am #936822DavidStaffCustomer SupportGlad we could be of help
June 24, 2019 at 4:40 am #939336SimonHey 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?
June 24, 2019 at 7:33 am #939629SimonJust 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?June 24, 2019 at 7:58 am #939656SimonOh, 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.
June 24, 2019 at 9:01 am #939729TomLead DeveloperLead Developersticky.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).
June 24, 2019 at 9:29 am #939753SimonAhh 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.
June 24, 2019 at 1:56 pm #939932TomLead DeveloperLead DeveloperNo problem! We’ll be removing that file from WPSP soon anyways. Perfmatters is a great plugin to have π
January 3, 2021 at 1:39 pm #1604177ErikHi 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?
January 3, 2021 at 5:02 pm #1604272ElvinStaffCustomer SupportHi,
You can try this instead (
wp_enqueue_scripts
):add_action( 'wp_enqueue_scripts', function() { wp_dequeue_style( 'wpsp-matchHeight' ); }, 100 );
January 3, 2021 at 6:47 pm #1604310ErikThanks 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 thewpsp_settings
andwpsp_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 π
-
AuthorPosts
- You must be logged in to reply to this topic.