What are the advantages of leaving out out the protocol for src=?

39 views Asked by At

I see that the src URL for jQuery has no protocol specified:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<script>

Is this standard? What are the pros and cons of leaving out the protocol?

1

There are 1 answers

0
msg On

It's a shorthand. It'll use whatever protocol the current source is using without having to state it explicitly and avoiding possible mixed content warnings.

See the RFC, sections 3 and 4.2