Problem

I noticed this issue when using an entity browser to display media bundles. One of them is a twitter media entity. The twitter widget gets loaded as it should, but we get a few errors in the console saying twttr is not defined.

Proposed solution

The issue is in the twitter.js file, where we check if twttr is not defined and load it from the //platform.twitter.com/widgets.js instead, but we have no guarantee that this file gets loaded before the init function gets called. Therefore, we need to call the init function in a callback (e.g. on script load: https://javascript.info/onload-onerror).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sasanikolic created an issue. See original summary.

sasanikolic’s picture

Issue summary: View changes
sasanikolic’s picture

Status: Active » Needs review
FileSize
466 bytes

Here is the patch with the proposed solution.

sasanikolic’s picture

I think we should also call init when twttr is defined.