dinbror / blazy

Hey, be lazy! bLazy.JS is a lightweight pure JavaScript script for lazy loading and multi-serving images. It's working in all modern browsers including IE7+.
http://dinbror.dk/blazy
MIT License
2.62k stars 354 forks source link

Not working with webpack Encore #169

Open etshy opened 6 years ago

etshy commented 6 years ago

I got this error after webpackEncore compilation

Uncaught ReferenceError: Blazy is not defined
    at HTMLDocument.<anonymous> (reader_init.js:215)
    at mightThrow (jquery.js:3534)
    at process (jquery.js:3602)
cjhaas commented 5 years ago

When you import through webpack, blazy is used as a module and not bound to the global window object. So in your code you need to also import it using something like:

import Blazy from '../node_modules/blazy/blazy';

This will then give you access to use Blazy as a constructor