In HTML when referencing images, css, javascript, etc… I sometimes use links without the http or https scheme portion, à la. <img src="//www.example.com/dir/file.gif" alt="" /> and I haven’t had any browsers choke on it yet (that I know of). I’ve seen a few other public sites use it as well, but not many.
I even reference the Google jQuery CDN with this syntax on an e-commerce site:
<script src="//ajax.googleapis.com/ajax/.." type="text/javascript"></script>
Obviously, I only do this when I know the server has both http and https capabilities. (Usually my own sites)
So my question is what harm can this cause? What are the pitfalls or downsides?
It will not harm anyway. Actually, if you write src=”http://ajax.googleapis.com/ajax/.. and your user will browse site over HTTPS then browser will warn user that parts of the site uses HTTP. It is better to use // notation for such cases.