Drop protocol in URIs
So this protip is very simple.
DO: //somesite.com/somepath/somefile.js
or relative /somepath/somefile.js
DON'T: http://somesite.com/somepath/somefile.js
If you use //somesite.com/somepath/somefile.js
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 https://somesite.com/somepath/somefile.js
.
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.
Excellent!
Written by Alexander Brevig
Related protips
3 Responses
Should there be a colon here? https//somesite.com/somepath/somefile.js.
Of course
I was hoping you would answer "NO because you shouldn't fill in the protocol" ;) awesome tip though