Last Updated: February 25, 2016
· alexanderbrevig

Drop protocol in URIs

So this protip is very simple.

DO: // or relative /somepath/somefile.js


If you use // for all your references, the browser will fill in the protocol for you. So if you're visiting the page with https, the ref will become

I recently had to make on of my sites be HTTPs compliant. Luckily it was as easy as setting up an SSL and change the default protocol for my sites.
Because of this trick, I had no insecure resources and no warnings on my site.


3 Responses
Add your response

Should there be a colon here? https//

over 1 year ago ·

Of course

over 1 year ago ·

I was hoping you would answer "NO because you shouldn't fill in the protocol" ;) awesome tip though

over 1 year ago ·