Is there a way to detect if the Facebook Javascript SDK loaded ...

You should load the Javascript Library Asynchronously and put all your FB related functions inside the window.fbAsyncInit method:

Lee mas