Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre existing window.twttr object causes uncaught errors #51

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

matt-sanders
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant