dav_i
dav_i

Reputation: 28107

jQuery CDN secure/insecure loading issues

I'm experiencing an issue with the jQuery CDN.

Given the following script imports:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

I am having the following issues with the CDN paths:

  1. Using http://... when accessing my site over SSL I get

    [blocked] The page at https://www.example.com/ ran insecure content from http://code.jquery.com/jquery-1.9.1.js.

  2. Using https://... seems a bit dodgy if not accessing site over SSL
  3. Using //... causes both the imports to fail on GET.
What is the correct way of importing jQuery from CDN with a site that can be accessed both securely and not.

Upvotes: 1

Views: 4052

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

just omit the protocol, then the script will be loaded using the same protocol as the page

<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

But if the resource is loaded form the file system(with file:// protocol) then this will not work

Upvotes: 10

Related Questions