Correct way to add a tweet button? I'm trying to add a tweet button to my node.tpl.php in Drupal 6 - https://dev.twitter.com/docs/tweet-button.

I literally place the html+javascript within node.tpl like so:

&lt;a href="https://twitter.com/share" class="twitter-share-button" data-lang="en"&gt;Tweet&lt;/a&gt;
&lt;script&gt;!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");&lt;/script&gt;&lt;




The result is a flickering button every time I refresh, so I'm thinking the javascript is loading incorrectly?

Ideally, I'd like to load the javascript within page.tpl.php, and ensure that it applies to node.tpl, but it doesn't appear to be working. I've also tried loading it using drupal_add_js within template.php various preprocessor methods.

I rather not use any of the social media modules - such as AddToAny, ShareThis, or ServiceLinks - partly because I feel this should be cut and dry w/o module dependency. 

So I guess my question is - what is the best way to load that twitter javascript code within node.tpl to avoid the flickering button?
Do not place the &lt;script&gt; tag in node.tpl.php because it will repeat if multiple nodes are arranged to appear in a single page.

Use following code to add js in page and call this function in hook_init() or in your page's callback function.

drupal_add_js('&lt;script&gt;...&lt;/script&gt;',array(
  'type' =&gt; 'inline', 
  'scope' =&gt; 'footer'
));