[Resolved] WP Show Post JavaScript 1.14.2

Home Forums Support [Resolved] WP Show Post JavaScript 1.14.2

Home Forums Support WP Show Post JavaScript 1.14.2

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1447925
    maxime

    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

    #1447930
    Elvin
    Staff
    Customer Support

    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.

    #1448557
    maxime

    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

    #1448632
    David
    Staff
    Customer Support

    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.

    #1448642
    maxime

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

    #1448824
    David
    Staff
    Customer Support

    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.

    #1448880
    maxime

    Perfect, I’ll do that. Thank you πŸ™‚

    #1449301
    David
    Staff
    Customer Support

    You’re welcome

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