• Resolved aimdoll

    (@aimdoll)


    Hello,

    I am attempting to improve site performance on the site linked above. With that being said, I want to dequeue/deregister or remove the action that is enqueuing scripts for akismet for logged out users and on certain pages where the javascript does not need to be ran. I have tried dequeuing and deregistering via the child theme but have not had any success. Can you please tell me how I can do this via dequeuing or removing the action that calls the enqueue function. Thanks in advance for any help you might be able to provide on this topic.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Christopher Finke

    (@cfinke)

    Something like this should work:

    
    add_action( 'comment_form', 'dequeue_akismet_js', 99 );
    
    function dequeue_akismet_js() {
        wp_dequeue_script( 'akismet-frontend' );
    }
    

    But can you tell me more about when the JS is being enqueued when it’s not necessary? Maybe we can fix it for everyone in the plugin itself.

    Thread Starter aimdoll

    (@aimdoll)

    Hello Christopher,

    Thank you so much! I am very impressed by your response time. Have a fantastic day!

    Best Regards,

    Amy Singleton

    Thread Starter aimdoll

    (@aimdoll)

    Hello Again,

    I tried the snippet provided in the child theme and via a plugin. Unfortunately it does not work. Thoughts?

    Best Regards,

    Amy Singleton

    • This reply was modified 1 year, 5 months ago by aimdoll.
    Plugin Author Christopher Finke

    (@cfinke)

    Try this; as long as it is in your child theme’s functions.php file or in another plugin, this should ensure that the script is dequeued. The previous snippet might not have worked depending on when it was run in the hook firing sequence.

    add_action( 'init', 'dequeue_akismet_js', 99 );
    
    function dequeue_akismet_js() {
        remove_action( 'comment_form', array( 'Akismet', 'load_form_js' ) );
    } 
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Dequeue Scripts’ is closed to new replies.