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

ALL the registered bloks are loaded on the client even when not used on the current page #886

Open
1 task done
Dav3rs opened this issue Jul 26, 2024 · 8 comments
Open
1 task done
Assignees
Labels
investigation [Issue] The Storyblok team is investigating pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised

Comments

@Dav3rs
Copy link

Dav3rs commented Jul 26, 2024

Describe the issue you're facing

I notice that my page was crashing due to scripts being executed that have nothing to do with the current page content.

It looks that ALL the storyblok components registered in the project are sent to client even when they are not needed in the current page consumed stories.

For example

1- I create a component that is not used on the page
image

2- With the next content
image

3- It it loaded 🫤
image

Reproduction

https://stackblitz.com/~/github.com/Dav3rs/astro-storyblok

Steps to reproduce

No response

System Info

Linux, astro latest, node lts.

Used Package Manager

npm

Error logs (Optional)

No response

Validations

@Dav3rs Dav3rs added pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised labels Jul 26, 2024
@mediabeastnz
Copy link

I'm seeing the same thing, even on deployed sites astro build.

I'd put this high on the priority list as it could definitely effect performance and cause had to debug issues.

@mediabeastnz
Copy link

After looking into this more it looks like this is expected behaviour from Astro. any script tags are automatically hoisted and loaded as JS modules.

A workaround if this causes issues I guess is to have the script inline or add attributes to the script tag.

@Dav3rs
Copy link
Author

Dav3rs commented Aug 20, 2024

@manuelschroederdev This is a huge flaw of the astro integration, it should be prioritized don't you think so?

@alvarosabu alvarosabu self-assigned this Aug 20, 2024
@dipankarmaikap dipankarmaikap added the investigation [Issue] The Storyblok team is investigating label Aug 22, 2024
@dipankarmaikap
Copy link
Contributor

@Dav3rs , Thank you for bringing this issue to our attention. We're actively investigating it and will keep you updated with our findings. If we identify any workarounds or solutions, we’ll share them with you here and document them for other users as well.

@markpinero
Copy link

There’s no way to integrate dynamic components without a change in how Astro changes their build process. Related discussion: withastro/astro#4863

@moritzlaube
Copy link

We have opened an issue quite a while ago that is discussing the exact same problem. Just to get everyone on the same page: withastro/astro#4863 (comment)

And I still think it is a crucial thing, especially when working with a CMS.

@moritzlaube
Copy link

Sorry @markpinero, I just saw that you were referring to it already.

@moritzlaube
Copy link

Hi everyone! I've started a discussion about tree-shaking unnecessary components for static builds with CMS page builders here: withastro/roadmap#1054

Would love to hear your thoughts! My knowledge is clearly limited, so please weigh in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation [Issue] The Storyblok team is investigating pending-author [Issue] Awaiting further information or action from the issue author pending-triage [Issue] Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

6 participants