Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does twitter's share button add data-twttr-rendered="true" to my body tag?

Just curious. Why would it need access to that part of the DOM, and not just the part it's manipulating?

like image 977
Cameron Hurd Avatar asked Jan 02 '13 14:01

Cameron Hurd


1 Answers

Seems to be that the twitter button's render callback needs to know if the whole page has been rendered (especially if you have more than one on a page), and the body tag is an obvious place to store that information by means of an attribute...

Tweet button docs: https://dev.twitter.com/docs/tweet-button

Look up also twttr.TweetButton and its method render()

For confirmation have an explore of this code: http://platform.twitter.com/widgets.js (do a search for data-twttr-rendered to see it used - it is minified unfortunately however!)

like image 100
Coder Avatar answered Sep 30 '22 18:09

Coder