New Landing How can we help? Cardinal Not load Google Maps API

Viewing 10 posts - 1 through 10 (of 10 total)
  • Posted in: Cardinal
  • #140339
    rwolfenden
    Member
    Post count: 66

    Hi,

    Is there any way to hide the Google Maps API? I use a different plug in which in itself loads the API and its being called twice now on the page.

    Thanks
    Rob

    #140386
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    I’ll forward this to my colleague who will be able to help you with this

    – Kyle

    #141011
    rwolfenden
    Member
    Post count: 66

    Thanks Kyle.

    #141145
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    Inside functions.php you can comment/delete the following line.

    wp_register_script( 'sf-maps', '//maps.google.com/maps/api/js?sensor=false', 'jquery', null, true );

    -Rui

    #153342
    Reason1234
    Member
    Post count: 4

    Hi,

    Is there a way to do this in child theme function file?

    Don’t want to edit parent theme functions.php as this will be wiped by updates.

    Thanks, Rhys

    #153344
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    Yes it exist and it’s the best way to do it.
    Try adding this line in your child theme functions.php

    
    wp_deregister_script( 'sf-maps');
    

    -Rui

    #153351
    Reason1234
    Member
    Post count: 4

    Thanks, tried it but still getting the following line appearing:

    <script type=’text/javascript’ src=’/maps/api/js?sensor=false’></script>

    Any ideas?

    #153359
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Forgot that the code should assigned with a hook, so it can be removed in the precise moment.

    Replace by this

    
    add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
    
    function my_deregister_javascript() {
    	wp_deregister_script( 'sf-maps');
    }

    -Rui

    #153364
    Reason1234
    Member
    Post count: 4

    That’s perfect, many thanks.

    #153368
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Thanks Rui

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register