Get current protocol from URL (http or https)

To get the protocol used for the current page: var protocol = window.location.protocol