metafizzy / flickity

:leaves: Touch, responsive, flickable carousels
https://flickity.metafizzy.co
7.53k stars 602 forks source link

Mailchimp embed ReferenceError: Flickity is not defined, due to conflict #831

Closed chrisbaconxyz closed 6 years ago

chrisbaconxyz commented 6 years ago

I am getting a reference error to due conflict with a Mailchimp script. The conflict seems to be halting the initialization of Flickity.

Test case: https://jsbin.com/pojikuxiye/edit?html,console

I have found if the Flickity script is loaded prior to the Mailchimp script, there is no issue. This is not doable for my use case where the Flickity is only loaded on some pages if needed, after all other scripts.

desandro commented 6 years ago

Looks like the Mailchimp embed is including a RequireJS itself, so Flickity will not be added as global. Instead, you can require flickity/js/index.

See demo https://jsbin.com/gefoyimiri/edit?html,console

    require( ['flickity/js/index'], function( Flickity ) {
      console.log(Flickity)
    })
chrisbaconxyz commented 6 years ago

Fixed. thanks!