How to workaround 'FB is not defined'?

前端 未结 12 1250
余生分开走
余生分开走 2020-12-04 17:56

Sometimes I\'m getting the \"FB is not defined\" issue when loading the http://connect.facebook.net/en_US/all.js

I\'ve realized that the problem is because sometime

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 18:22

    I think you should solve the main issue instead, which solution is provided by Facebook (Loading the SDK Asynchronously):

    You should insert it directly after the opening tag on each page you want to load it:

    
    

    From the documentation:

    The Facebook SDK for JavaScript doesn't have any standalone files that need to be downloaded or installed, instead you simply need to include a short piece of regular JavaScript in your HTML that will asynchronously load the SDK into your pages. The async load means that it does not block loading other elements of your page.

    UPDATE: using the latest code from the documentation.

提交回复
热议问题