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

Any way to avoid loading FxParallax assets? #27

Closed
phaberest opened this issue Aug 17, 2023 · 4 comments · Fixed by #29
Closed

Any way to avoid loading FxParallax assets? #27

phaberest opened this issue Aug 17, 2023 · 4 comments · Fixed by #29

Comments

@phaberest
Copy link

phaberest commented Aug 17, 2023

I see that the css for FxParallax is adding an item to my request chain and since I am not using any of its features in this project I would like to disable it and just keep the Img side, is there any way to do it?

I imported as import Img from '@zerodevx/svelte-img' everywhere

@zerodevx
Copy link
Owner

zerodevx commented Aug 17, 2023

I don't quite understand your question tbh?

<script>
  import Img, { FxParallax } from '@zerodevx/svelte-img'
  import src from '$lib/a/cat.jpg?as=run'
</script>

<!-- Img component -->
<Img {src} />

<!-- Img component with Parallax -->
<FxParallax {src} />

Edit: oh do you mean FxParallax is not tree-shaken away? If you didn't import FxParallax at all in your project, then its related code should be automatically excluded from your build.

@phaberest
Copy link
Author

phaberest commented Aug 17, 2023

Thank you @zerodevx, that's exactly what I mean. I never used it anywhere in the project, but it's getting loaded in the final build anyway.

I installed it as usual, no difference from standard edits to vite.config.js for imagetools and importing Img where needed.

But as you can see, it is part of the bundle: https://nexuser.it/_app/immutable/chunks/FxParallax.svelte_svelte_type_style_lang.2717a0f6.js

@zerodevx
Copy link
Owner

zerodevx commented Aug 18, 2023

Hey, so two things:

But as you can see, it is part of the bundle: https://nexuser.it/_app/immutable/chunks/FxParallax.svelte_svelte_type_style_lang.2717a0f6.js

Firstly, this chunk includes code from v1 - they are removed from v2. Could you check that you're on @zerodevx/svelte-img@2?

Secondly, I tried reproducing this on a fresh project and can confirm that I did get a build chunk named FxParallax.svelte*.js - despite not importing the parallax component anywhere. I'm still investigating, but AFAICT, the actual FxParallax code isn't anywhere in the chunk. So I'm inclined to think that it's just a badly named tree-shaken chunk. 🤷

Edit: can confirm that FxParallax is not tree-shaken away - surprised why that's happening tbh.

@zerodevx
Copy link
Owner

This should be fixed with v2.0.2. Thanks for bringing this to attention - great catch! 👍

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 a pull request may close this issue.

2 participants