Live data from Hacker News

Google +1 Button Performance Review

aaronpeters.nl

1–10 of 29 posts

Re: Google +1 Button Performance Review

#2
In short, and as a rule with all scripts, load scripts asynchronously / non-blocking when possible, including Google +1.

    
    (function(d, t, g, s){
    g = d.createElement(t),
    s = d.getElementsByTagName(t)[0];
    g.async = true;
    g.src = 'https://apis.google.com/js/plusone.js';
    s.parentNode.insertBefore(g, s);
    })(document, 'script');
    
Load it as far up your page as possible, as to benefit from the parallelism early on and not hanging it off the end of or extending your page load.

Re: Google +1 Button Performance Review

#5
post #4

Someone at Google should get a slap upside the head for not getting this spot on. Google is evangelising performance on one hand and making careless errors on the other...

Yeah, how dare they say the lowest-performing option first in an in-passing comment! What if the user knows nothing about performance and stops there! Their page will load 8 milliseconds less quickly! Amateur hour!11!

()

Re: Google +1 Button Performance Review

#6
post #5
post #4

Someone at Google should get a slap upside the head for not getting this spot on. Google is evangelising performance on one hand and making careless errors on the other...

Yeah, how dare they say the lowest-performing option first in an in-passing comment! What if the user knows nothing about performance and stops there! Their page will load 8 milliseconds less quickly! Amateur hour!11! ( )

From a brief reading, it's potentially worse than an 8ms slow-down if you take all the issues into account. Have I misinterpreted?

Re: Google +1 Button Performance Review

#7
Google has added the +1 option to all their search requests / results, I'm sure if the performance was such an issue they would of found a way to fix it as it would degrade their page load times, granted I'm sure it's not the same 'exact' code.

Re: Google +1 Button Performance Review

#8
post #7

Google has added the +1 option to all their search requests / results, I'm sure if the performance was such an issue they would of found a way to fix it as it would degrade their page load times, granted I'm sure it's not the same 'exact' code.

The +1 widget on the search results page and other 1st party pages is different than the +1 widget for 3rd party publishers. 3rd parties have to use an iframed widget to prevent click fraud.

Re: Google +1 Button Performance Review

#9
post #2

In short, and as a rule with all scripts, load scripts asynchronously / non-blocking when possible, including Google +1. (function(d, t, g, s){ g = d.createElement(t), s = d.getElementsByTagName(t)[0]; g.async = true; g.src = 'https://apis.google.com/js/plusone.js'; s.parentNode.insertBefore(g, s); })(document, 'script'); Load it as far up your page as possible, as to benefit from the parallelism early on and not han…

I suppose these are JS performance tricks?

- Define g and s as parameter even though they're only given a value inside the function

- Pass document into the function instead of using it from global scope

- Insert a script tag in front of the other script tags on-the-fly using insertBefore, instead of simply doing ...

Pretty interesting. Care to explain a bit?

Re: Google +1 Button Performance Review

#10
The ironic thing about Google's +1, which is meant to get you more clicks on SERPs (as you'll see your friends +1's [1]), is that as Google now use site speed in their ranking algorithm [2]. adding the +1 button to your site would actually make it rank lower.

There's another performance review of +1 here [3], which compares it to the Facebook Like button. Steve Souders (who's written books on web performance) has detailed and compared a few other 3rd party JavaScript buttons and widgets here [4].

[1] http://adage.com/article/digital/google-adds-button-foray-so...

[2] http://googlewebmastercentral.blogspot.com/2010/04/using-sit...

[3] http://www.artzstudio.com/2011/06/googles-button-is-slow-and...

[4] http://stevesouders.com/p3pc/

Post reply on HN