Javascript running twice when not logged in
I finally found out what was causing this issue. It was a module named Drupal for Firebug. 
So, if anyone finds this, disable this module and you will be fine.