Skip to content

Instantly share code, notes, and snippets.

@sleekslush
Created May 16, 2012 20:01
Show Gist options
  • Save sleekslush/2713507 to your computer and use it in GitHub Desktop.
Save sleekslush/2713507 to your computer and use it in GitHub Desktop.
HTTP protocol logic in javascript
// Stupid as shit
var url = (("https:"==document.location.protocol)?"https":"http") + "://domain.com/file.js";
// Better
var url = document.location.protocol + "//domain.com/file.js";
// Best (protocol-less FTW!)
var url = "//domain.com/file.js";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment