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

Support module loading priority #16523

Open
4 tasks done
KermanX opened this issue Apr 24, 2024 · 0 comments
Open
4 tasks done

Support module loading priority #16523

KermanX opened this issue Apr 24, 2024 · 0 comments
Labels
enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority) performance Performance related enhancement

Comments

@KermanX
Copy link

KermanX commented Apr 24, 2024

Description

Here are two use cases:

  1. Suspend warmup requests if there are already some other requests from the browser

Assume there are some time-consuming modules. Firstly we load the app's framework (including a loading animation), and then the app dynamically imports the time-consuming modules, so that users can watch the loading animation while waiting.

The problem is that if the user opens the browser page moments later after the server starts, it would be better if the time-consuming modules could be warmed up during this time. But if we set the warnup option to those modules, the loading & transformation of them will start eagerly, which blocks the app framework (which should be of higher priority) from loading.

Currently, only modules that are intended to load synchronously can take advantage of warmup because of the above problem.

  1. Load a chain of modules one by one

Take Slidev as an example: There are many slides in a Slidev app, and each slide as a module takes a long time to load. If we load all of them in parallel, users have to wait for a long time for the slides, including the slide they are watching. The ideal way to load these modules is to load them one by one, which means the closer the slide is to the active slide, the higher priority it will be of.

Suggested solution

I don't know.

Alternative

For the second use case, there are some complex ways to make it, such as setting a timeout after one slide is loaded to load the next slide. But this can't make use of Vite's parallel loading feature and doesn't have the best performance.

Additional context

I am wondering if this use case is really common. Because Vite is designed as a dev server, but Slidev uses Vite as the backend 😂. I am also wondering if Vitest will also benefit from this feature.

Validations

@patak-dev patak-dev added enhancement New feature or request performance Performance related enhancement p2-nice-to-have Not breaking anything but nice to have (priority) and removed enhancement: pending triage labels Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority) performance Performance related enhancement
Projects
None yet
Development

No branches or pull requests

2 participants