Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

script src="//ajax.googleapis.com, where is the http?

I haven't been able to figure this out, but for some reason when I use the google libraries and look for a script to use (https://developers.google.com/speed/libraries/devguide#jquery), they are provided without the http... why is that? I've also noticed that google is now doing this on Youtube embed code (which causes my ckeditor youtube embed plugin to see this as an invalid src for an iframe).

Example (without http):

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

Why not this (with http):

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

I have a feeling it has something to do with merging everything over to https. Perhaps this is preparation?

like image 627
Tony M Avatar asked Aug 07 '13 19:08

Tony M


1 Answers

Basically it allows the browser to determine whether to use http:// or https:// based on the protocol that your page is using. If your page is on https then it will use https to get the scripts. Because if you hard code to say http and you page is using https then the browser will throw errors telling the user that the site might not be safe for instance. Bottom line always use relative URL for scripts, images and all resources and don't hard code the http protocol.

like image 106
Tib Avatar answered Oct 23 '22 03:10

Tib