Skip to content

Instantly share code, notes, and snippets.

@giacomopaita
Last active February 18, 2017 00:02
Show Gist options
  • Save giacomopaita/8ae8d7d6bc450bfab0ee to your computer and use it in GitHub Desktop.
Save giacomopaita/8ae8d7d6bc450bfab0ee to your computer and use it in GitHub Desktop.
Lazy Load Facebook Like Box
<div id="fb-root"></div>
<div class="fb-like-box" data-href="https//www.facebook.com/[CostaKreuzfahrten[PAGE]" data-width="958" data-height="353" data-colorscheme="light" data-show-faces="false" data-header="false" data-stream="true" data-show-border="false">
$('.tab a').on('click', function(){
if ($(this).html() == 'FACEBOOK' && typeof xx == 'undefined') {
// DUMMY VARIABLE TO CALL THE FUNCTION ONLY THE FIRST TIME THE USER CLICKS THE TAB:
xx = 1;
(function(d, s, id) {
var js;
var fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
$('#facebook-jssdk').load(function(){
FB.XFBML.parse();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment