$(document).ready(function(){
console.log('a');
});
window.fbAsyncInit = function() {
FB.init({appId: '{/literal}{$fbAppId}{literal}',
status: true,
cookie: true,
xfbml: true});
FB.Event.subscribe('edge.create', function(response) {
// Do something, e.g. track the click on the "Like" button here
if(!liked)
{
{/literal}$.get('http://{$rooturl}/promotions/likecheck.php?CID={$CID}&ctype={$campaignTable}');{literal}
liked=true;
}
});
};
(function() {
console.log('b');
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
I'm noticing that when I run this javascript in my console i get the output:
b
a
I'm wondering what does it mean to wrap a function in parenthesis in javascript such as here:
(function() {
console.log('b');
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
Is the intention of doing this to make this function the first executed in a script tag?