Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Boutons Like et +1 en asynchrone
<?php
//Pour Facebook, apres avoir appele FB.init, charger connect js en asynchrone
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : xxx,
session : xxx,
status : true,
cookie : true,
xfbml : true
});
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
// Pour +1, on est obligé de passer par jQuery, donc:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.getScript('https://apis.google.com/js/plusone.js');
$('.partageplusone').append('<div class="widget"><div class="g-plusone" data-size="tall" data-count="true">/div></div>');
});
</script>
// Et ensuite tu ajoutes ton bouton +1 avec la div .partageplusone
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.