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

I couldn't figure it out, but for some reason, when I use google libraries and look for a script to use ( https://developers.google.com/speed/libraries/devguide#jquery ) they are provided without http ... why? I also noticed that google now does this on Youtube embed code (which causes my ckeditor youtube embed plugin to see this as an invalid src for 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 that it has something to do with bringing everything together to https. Perhaps this is preparation?

+6
source share
3 answers

This basically allows the browser to determine whether to use http: // or https: // based on the protocol used by your page. If your page is on https, it will use https to receive scripts. Because if you are hard-coded to say http, and the page uses https, the browser will throw errors telling the user that the site may be unsafe, for example. The bottom line always uses the relative URL for scripts, images, and all resources and does not hardcode the http protocol.

+6
source

This is a relative URI. It supports the same scheme as the requested page when changing the host and everything else.

0
source

Read the protocol-related URLs , which is one way to prevent annoying โ€œThis page contains both safe and unprotected elementsโ€ in IE, while storing the entire request for your asset within the same protocol.

0
source

Source: https://habr.com/ru/post/951251/


All Articles