Sometimes window.twttr will exist without the widgets property. This could be due to twitter analytics or ads. I came across this when twitter scripts were being embedded on a site via GTM. This results in a bunch of errors, specifically:
Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating '(t=e.widgets).createTweetEmbed')
The current implementation checks to see if window.twttr is defined before trying to load the twitter platform scripts. The solution here is to also check that window.twttr.widgets is available.
Sometimes
window.twttr
will exist without thewidgets
property. This could be due to twitter analytics or ads. I came across this when twitter scripts were being embedded on a site via GTM. This results in a bunch of errors, specifically:The current implementation checks to see if
window.twttr
is defined before trying to load the twitter platform scripts. The solution here is to also check thatwindow.twttr.widgets
is available.