According to the Codex, wp_enqueue_script supports protocol relative, or protocol agnostic external links: “Remote assets can be specified with a protocol-agnostic URL, i.e. ‘//otherdomain.com/js/theirscript.js’.”

But I’m not seeing it:

wp_enqueue_script('google-maps', '//maps.googleapis.com/maps/api/js?&sensor=false', array(), '3', true);

Output:

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

Notice that the protocol relative URL is appended to the site URL.

1

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 Reply

Your email address will not be published. Required fields are marked *