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

Using lazysizes.min breaks RIAS intermittently when using React #551

Closed
joacim-boive opened this issue Oct 30, 2018 · 2 comments
Closed

Comments

@joacim-boive
Copy link

joacim-boive commented Oct 30, 2018

lazysizes: 4.1.4
react: 16.6.0

The problem is that {width} sometimes isn't replaced. And I mean sometimes...

Have been struggling with this for a long time and cracked it by accident today while creating this bare-bone example repo to illustrate the problem: https://github.com/joacim-boive/lazysizes-debug

I don't know if the cause is that the already minified file somehow breaks because it's minified again or if I'm doing something stupid — it's probably the latter... ;)

Anyway, using create-react-app as I did in the repo above as well as our home rolled webpack build script has this problem and the solution is NOT to import lazysizes.min.js and instead import the unmodified versions and then everything works.

Maybe this is already stated in the docs, but I just thought I'd mentioned it here as well.

Or, have I implemented it incorrectly somehow?

@aFarkas
Copy link
Owner

aFarkas commented Oct 30, 2018

@joacim-boive
The reason for this issue is the following: Although lazySizes has one global it supports multiple modules (you can install multiple versions of lazySizes on one site) and all plugins do require lazySizes, which means if you require the minified version you have included lazySizes twice. If the minified version now finds an image the plugins do detect that this is not the version of lazySizes they are bound to and do nothing here.

The best way is that I remove all *.min.js files from future npm.

@joacim-boive
Copy link
Author

Aha! So, there you go. Thanks! :)

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

No branches or pull requests

2 participants