How to fix: Duplicate id fb-root.

Most Likely Cause and Fix

Your page contains more than one Facebook plugin (such as the Like button) and your markup incorrectly includes the Facebook Javascript SDK more than once.

You must include the Javascript SDK only once, ideally right after the opening <body> tag, and then place the code for the plugin wherever you want the plugin to appear.

Refer to the Facebook plugin documentation for the plugin you are using and refer to the given code samples for details on how to do this.

A relevant blog post demonstrates this process for the Like button.

What This Error Means

In order to uniquely identify a single element, the value of the id attribute must be unique within the given document.

In the context of Facebook plugins, a div element with a specific ID attribute is required when including the Facebook JavaScript SDK:

<div id="fb-root"></div>

This error occurs when you incorrectly include the above line more than once.

How To Fix It

You must include the Javascript SDK only once, ideally right after the opening <body> tag, and then place the code for the plugin wherever you want the plugin to appear.

Refer to the Facebook plugin documentation for the plugin you are using and refer to the given code samples for details on how to do this.

A relevant blog post demonstrates this process for the Like button.

Discuss, Comment and Improve

Did this help you? Can this page be improved? Let us know!

comments powered by Disqus