Skip to content

Instantly share code, notes, and snippets.

@stephanschubert
Created June 7, 2011 17:48
Show Gist options
  • Save stephanschubert/1012736 to your computer and use it in GitHub Desktop.
Save stephanschubert/1012736 to your computer and use it in GitHub Desktop.
Optimized Google PlusOne Javascript - Asynchronous/Non-Blocking, Minimal + SSL Fix
<!-- Place this tag just before your close body tag and NOT in your <head> -->
<script>
(function(d, t) {
var 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');
</script>
@pi3r
Copy link

pi3r commented Jun 27, 2011

Hi, thanks for this gist, do you know how i can pass the lang parameter using your script?
*** edit ***
That line seems to work fine :
g.textContent = "{lang: 'fr'}";

@stephanschubert
Copy link
Author

I would use the the HTML attribute on each button instance:

<div lang="fr" class="g-plusone" data-count="true" data-size="small" href="..."></div>

@Eroan
Copy link

Eroan commented Jun 29, 2011

It doesn't work Jazen.

Even using the data-lang="fr" doesn't...

It seems the only way to set-up another language is to use the basic structure {lang: 'fr'} !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment