Why would certainly you make use of document.location.protocol as opposed to simple// prefixed links?

As an example Google Analytics makes use of document.location.protocol in the boilerplate for monitoring:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

as opposed to

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = '//www.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

The ssl. sub-domain is a mute argument as https://www.google-analytics.com/ga.js functions flawlessly well.

Recognizing Google this more than likely is not an oversight. Exists a concern with particular internet browsers not sustaining the// method honouring shorthand or exists another thing I'm missing out on?

MODIFY: This does not simply relate to Google Analytics (various sub-domain instance). The very same point shows up on the Font Loader API page:

wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
    '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
0
2019-05-04 00:51:17
Source Share
Answers: 2

You currently mentioned the distinction when it comes to Google Analytics, particularly that the safe and secure variation gets on https://ssl. as opposed to http://www.. While a safe and secure variation of the www might function, it can additionally be various to the ssl variation :

  • Different certifications for the ssl variation and also www variation.
  • Various code on each variation.
  • Various cookies set, details to the SSL domain name.

I do not recognize if any one of these relate to Google though. From a look the code seemed the very same.

0
2019-05-08 12:05:48
Source

At the very least has one trouble in IE due to the fact that it creates double downloads : http://www.stevesouders.com/blog/2010/02/10/5a-missing-schema-double-download/

0
2019-05-07 18:39:23
Source