I'm wondering if putting the script tag to load Facebook sdk js is good enough or should I leverage async script that Facebook provides?
For example this is how I load Facebook sdk js right now in WordPress
<?php wp_enqueue_script( 'facebook-api', '//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=' . $app_id . '&version=v2.0' ); ?>
It results in putting the <script>
tag at the bottom of the page. Or do I have to do this which is suggested by Facebook? I wonder what the difference is in terms of performance?
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'your-app-id',
xfbml : true,
version : 'v2.3'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
Aucun commentaire:
Enregistrer un commentaire