Use a relative URL for JavaScript, CSS & Images

A relative URL without a scheme is perfectly valid.

<script src="//www.example.com/script.js"></script>
<link href="//www.example.com/style.css" rel="stylesheet" type="text/css" />
<img alt="" src="//www.example.com/image.png" />
https://www.example.com:8080/some/resource?key=value#hash
\___/   \_____________/ \__/ \___________/ \_______/ \__/
  |            |         |         |           |      |
scheme        host      port      path       query   fragment
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment