user429620
user429620

Reputation:

Automatic selection : http or https javascript inclusion

Is it possible to automatically detect whether or not the page is accessed via http or https and then include a https://url.js or http://url.js ?

Is javascript included via https any different? I'm talking about cache age and so on?

Thanks, Wesley

Upvotes: 2

Views: 4302

Answers (1)

Michael Berkowski
Michael Berkowski

Reputation: 270647

Use a protocol-relative link, starting with // instead of http or https:

<script type='text/javascript' src="//path/to/file.js"></script>

Upvotes: 11

Related Questions