How can I enqueue protocol relative external (//ajax.googleapis.com/…) scripts?

The code you posted works fine and results in this in the HTML output:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&#038;ver=3"></script>

Tested on WordPress 3.5 with this code snippet:

add_action('wp_enqueue_scripts', 'test');
function test() {
  wp_enqueue_script('google-maps', '//maps.googleapis.com/maps/api/js?&sensor=false', array(), '3', true);
}

Leave a Comment