Last active
February 18, 2017 00:02
-
-
Save giacomopaita/8ae8d7d6bc450bfab0ee to your computer and use it in GitHub Desktop.
Lazy Load Facebook Like Box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.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