Skip to content

Instantly share code, notes, and snippets.

@sjmiles
Last active December 18, 2015 09:39
Show Gist options
  • Save sjmiles/5763113 to your computer and use it in GitHub Desktop.
Save sjmiles/5763113 to your computer and use it in GitHub Desktop.
<element name="google-plusone">
<script>
Polymer.register(this, {
ready: function() {
addInstance(this);
},
plusOneReady: function() {
// do stuff
}
});
var instances = [];
function addInstance(instance) {
instances.push(instance)
}
function notify(instance) {
instance.plusOneReady();
}
window.google_plusone_loaded = function() {
window.google_plusone_loaded = undefined;
instances.forEach(notify);
instances = undefined;
addInstance = notify;
};
var script = document.createElement('script');
script.url = 'https://apis.google.com/js/client:plusone.js?onload=google_plusone_loaded';
document.head.appendChild(script);
</script>
</element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment