WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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);


<script type='text/javascript' src='http://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.

share|improve this question
up vote 7 down vote accepted

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

<script type='text/javascript' src='//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);
share|improve this answer
Do you know it this is new in WordPress 3.5? – Michiel van Oosterhout Jan 25 '13 at 13:12
Protocol-relative URLs was added 7 months ago: core.trac.wordpress.org/ticket/16560 – Otto Jan 25 '13 at 16:25
Ok, so it's not the version of WordPress that I'm using. So what could cause the difference in behaviour? – Michiel van Oosterhout Jan 28 '13 at 9:59
Well, that code was added 7 months ago, but if you look at the ticket, it has a 3.5 milestone, so yes it's probably new behavior to 3.5. – Otto Jan 28 '13 at 22:13
Oh right, I was looking at the 'Version' field which was set to 3.1, but that's the version of WordPress at the time the ticket was created. – Michiel van Oosterhout Jan 29 '13 at 12:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.