Both the Tweet and Facebook Like buttons see the widgets; you add something like this to your HTML:
<script> !function(d,s,id){ var js,fjs=d.getElementsByTagName(s)[0]; if(!d.getElementById(id)){ js=d.createElement(s); js.id=id; js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js,fjs); } }(document,"script","twitter-wjs"); </script>
which dynamically adds a <script> element to the DOM, which then loads the actual JavaScript widget. Why is this done dynamically, instead of directly loading the widget (it's easier and cleaner):
<script src="https://platform.twitter.com/widgets.js"></script>
The only reason I can think of is that it delays the loading of the script until the page loads, but this can be done just as easily by putting <script> just before closing </body> .
source share