Site logo

Archived topic

WP Show Post JavaScript 1.14.2

7 replies · Started by maxime on September 17, 2020

Viewing posts 1–8 of 8

Hello,

First of all thank you it's a great theme.

I would like to remove the jQuery 1.12.4 which is unused.
I found out that it was only called from the plugin WP Show Post. And only when it is an Element Hook with shortcode or PHP at the end of a post, not on widget.
In my cPanel I moved this file, it seems like it didn't break the plugin and in PageSpeed Insight it removed the unused JavaScript as well so it was great but in GTmetrix it counts as a bad request which is less great.

So my question is, is it possible to remove this JavaScript 1.12.4 of the plugin WP Show Post without consequences ?
I found this code :

function my_jquery_enqueue() {
wp_deregister_script( 'jquery' );
}

add_action( 'wp_enqueue_scripts', 'my_jquery_enqueue' );

Is it any good?
Or would it be better to deactivate the Element Hook ?

Thank you,
Max

Before doing this, you must really be sure that no theme or plugin has a dependency on it.

If you're 100% sure there none, you can proceed with using this code.

add_action('wp_enqueue_scripts', 'no_more_jquery');
function no_more_jquery(){
    wp_deregister_script('jquery');
}

It's basically the same as the code you've provided except I've fixed the ‘ ’ syntax.

Or would it be better to deactivate the Element Hook ?

It won't remove the enqueued jQuery as this is automatically loaded in WordPress by default regardless if its used or not. The WP native wp_deregister_script() function is the way to unload this.

Thank you for fixing the code.

Just one last question, when you say

no theme or plugin has a dependency on it.

It's about JavaScript in general or just the jQuery 1.12.4 ?

Because about the jQuery 1.12.4 I looked for every plugin by deactivate them one by one and only WP Show Post was showing this request.

If it's about any JavaScript, is there a way to know if a plugin needs JavaScript ? And in this case I won't activate the function.

Thank you

Hi there,

GP by default does not request jQuery - unless you enable the Sticky Navigation, which is the only function that still relies on jQuery.

So if a plugin requires jQuery it should make the request for it.

Okay thank you I'll check every plugin then in the source code.

Check the Network tab on a private / incongito browser ( as there is no cache ) - to see if jQuery is requested :) Simply keep refreshing after each plugin activation.

Perfect, I'll do that. Thank you :)

You're welcome

This archived topic is closed to new replies.