Javascript src starts with //?

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-06-04T15:45:35Z Indexed on 2010/06/06 19:32 UTC
Read the original article Hit count: 296

Filed under:
|

I'm starting to see more and more script references show up like so:

<script type="text/javascript" src="//somedomain.com/somescript.js"></script>

Note the lack of http: at the beginning of the src attribute.

It seems to work fine and avoids the messy requirement of detecting http vs https, but I've never actually seen this uri format referenced anywhere. Where did it come from? Is this behavior documented anywhere? Is it guaranteed to work in any browser?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about uri