On the "Google+ Sign-In for server-side apps" help page, in "Step 3: Include the Google+ script on your page" the following snippet is suggested:
<!-- The top of file index.html -->
<html itemscope itemtype="http://schema.org/Article">
<head>
<!-- BEGIN Pre-requisites -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
</script>
<script type="text/javascript">
(function () {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://plus.google.com/js/client:plusone.js?onload=start';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
</script>
<!-- END Pre-requisites -->
</head>
<!-- ... -->
Now, what the second SCRIPT seems to do:
Now, my question is WHAT FOR? I mean, wouldn't doing:
<!-- The top of file index.html -->
<html itemscope itemtype="http://schema.org/Article">
<head>
<!-- BEGIN Pre-requisites -->
<script async src="https://plus.google.com/js/client:plusone.js?onload=start"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<!-- END Pre-requisites -->
</head>
<!-- ... -->
achieve the same thing? Why this extra wrapper function inserting the script?
The async attribute is a fairly new development that isn't supported by most versions of IE. google's code is essentially a cross-browser way to emulate async.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With