Currently, the FB.Share script tag is added to each and every instance of the facebookshare_button output. This is unnecessary and possibly harmful. The script is written in such a way as to be loaded once. It iterates through all of the fb_share objects and does its work to all of them at once.

The attached patch updates the module so that it loads the FB.Share script only once at the end of the page. It also makes the script tag themeable output so sites like ours can lazy-load the script.

CommentFileSizeAuthor
facebookshare_script.patch1.31 KBmgriego

Comments

aaronsnoswell’s picture

I can confirm that this is happening, and that on my site it is breaking the FB share module. (It will display on some nodes, but not on others) - an error is logged to the console:

FB.init has already been called - this could indicate a problem (FB.Share:51)
Uncaught TypeError: Cannot call method 'getAttribute' of undefined (FB.Share:134)

Your patch file didn't work for me - the third hunk couldn't be applied. Going to try and fix it manually.

raulmuroc’s picture

Version: 6.x-1.0 » 7.x-1.3
Issue summary: View changes
Status: Needs review » Active

As not moving: the same in 7.x.

szt’s picture

Status: Active » Closed (duplicate)