Share Button - Uncaught TypeError: undefined is not a function


I think the problem may be a version of the Twitter widget.js file that is being supplied. I made a basic html page with only this as the code in the body:


The TypeError in the subject shows up in Chrome under the dev tools. In IE, " {exception} Object doesn’t support property or method ‘init’ " show up in the dev tools. This was code mostly taken directly from and still gives the same error. If anyone can confirm my hypothesis this would be nice.

Additional info from IE:
Anonymous function [Line: 44, Col: 1047], widgets.js
T.prototype.complete [Line: 1, Col: 3091], widgets.js
t [Line: 1, Col: 5177], widgets.js
T.prototype.complete [Line: 1, Col: 3091], widgets.js
N.prototype.complete [Line: 1, Col: 3997], widgets.js
C.prototype.complete [Line: 1, Col: 4609], widgets.js
C.prototype.exp [Line: 1, Col: 4849], widgets.js
Anonymous function [Line: 1, Col: 4546], widgets.js
T.prototype.then [Line: 1, Col: 2752], widgets.js
C.prototype.loaded [Line: 1, Col: 4527], widgets.js
n.onload [Line: 1, Col: 3759], widgets.js

The same type of information shows up in Chrome.
I have also asked this question on stackoverflow:


HI Joe,

If you are using events, you would need to use a slightly different version of the script that loads widgets.js (see the snippet in Example section here: You would have to use:

window.twttr = (function (d,s,id) { var t, js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js=d.createElement(s);; js.src=""; fjs.parentNode.insertBefore(js, fjs); return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } }); }(document, "script", "twitter-wjs"));

I have added a jsfiddle for your reference:

Hope that helps!


That helped a lot, thanks!

The odd part is that I was loading using that method originally and I could swear that I had tried the combination of code the same way in my trying to get the event binding to work again. The event binding originally worked just fine but then stopped causing me to play around trying to figure out what the root cause was.

I think that I have tried using a static twitter js call to alleviate a twttr is undefined problem. That in turn caused this problem. I’m just glad to be done chasing my tail on this issue, thanks!


The code you posted doesn’t seem to resolve this error for me. I also see it posted often around the web with no answer.

I’m trying to determine if I can get it working by adding in your code after the broken code has already loaded, but when I try that it gives no error but returns undefined for window.twttr, even though I just defined it. Any guidance would be appreciated.


Hi, thanks to share the example. It works for me in my chrome desktop but in my mobile does not work. (Chrome for android 40). I’ve been working woth tweet event.

Do you know why?



Do you have the Twitter app installed that opens the url? In that case the ‘tweet’ event will be broken as the native app has takes over and we can’t run javascript to send back a successful ‘tweet’ event.

closed #7