Search code examples
javascriptjquerywordpress

Remove a script using Jquery in WordPress


How can I disable or remove this script from loading using jquery(jQuery( document ).ready( function(){})). It is can not load in mainland of China, so makes loading extremely slow, I found the id of this element.

<script type="text/javascript" src="https://apis.google.com/js/platform.js?ver=1641328563" id="eael-google-api-js"></script>

enter image description here


Solution

  • Just copy and paste the following code to your functions.php and the script should be removed.


    /* Remove unwanted plugin Javascript file */
    function remove_eael_google_api_js() {
        wp_dequeue_script( 'eael-google-api');
        wp_deregister_script( 'eael-google-api');
    }
    add_action( 'wp_enqueue_scripts', 'remove_eael_google_api_js', 100);