Remove extra Google Maps script

EDIT :
use wp_enqueue_script as you want (enqueue in header or footer after jQuery as you want) to enqueue file called something like : gmap.js included in your plugin

wp_enqueue_script('custom-gmap', plugin_dir_url( __FILE__ ).'inc/js/gmap.js', array('jquery'), false, true);//just change your path and name of file

write this in your Js file 🙂

$(document).ready(function() {
    if (typeof google === 'object' && typeof google.maps === 'object') {
        return;
    }else{
        $.getScript( 'http://maps.google.com/maps/api/js', function() {});
    }
});

http://codepen.io/khaled-sadek/pen/WwvOGb

Leave a Comment