Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delay a javascript function until after Jquery & Facebook are both loaded?

Jquery provides a very convenient way to delay executing code until the DOM is fully loaded:

$(function() {
    dom_is_loaded();
});

The Facebook Javascript SDK, when loaded asynchronously, provides a similar mechanism:

window.fbAsyncInit = function() {
    fb_is_loaded();
}

What's the most elegant way to delay code from running until the DOM and Facebook's SDK have both fully initialized?

like image 253
Leopd Avatar asked Dec 28 '22 22:12

Leopd


1 Answers

Is there a reason why just doing

window.fbAsyncInit = function() {
    $(function() {
        both_loaded();
    });
}

doesn't work?

like image 182
hugomg Avatar answered Jan 21 '23 12:01

hugomg