Skip to content

Preloaded JS file triggers warning: "was preloaded but not used within a few seconds" in Laravel app using Vite #55793

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

Open
midsonlajeanty opened this issue May 20, 2025 · 1 comment

Comments

@midsonlajeanty
Copy link

Laravel Version

12.15.X

PHP Version

8.4

Database Driver & Version

Sqlite

Description

In my Larave 10.4.1 application using Vite for asset bundling, I'm getting the following browser warning in the console when i use aggresive prefetching:

The resource https:/<...>/app-l0sNRNKZ.js was preloaded using link preload but not used within a few seconds from the window's load event.
Please make sure it has an appropriate `as` value and it is preloaded intentionally.
This happens even though the app.js file is included with the `@vite('resources/js/app.js')` directive in my Blade layout, and the generated preload link uses `rel="modulepreload"`.

It appears that the asset is preloaded correctly, but the browser considers it unused shortly after load, possibly due to how Vite or Laravel delays its usage via dynamic import or defer.

Steps To Reproduce

Any laravel project

midsonlajeanty added a commit to midsonlajeanty/framework that referenced this issue May 20, 2025
Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants