spatie/laravel-mix-preload
Laravel package that adds a @preload Blade directive to automatically output preload/prefetch tags from your mix-manifest.json. Mark chunks by including “preload” or “prefetch” in the filename to optimize asset loading.
as="script"/as="style" attributes) out-of-the-box.preload-biglibrary.js to load heavy dependencies early.prefetch-* chunks for CSS/JS of predicted next pages (e.g., pagination, navigation links).prefetch-variant-b.css).Adopt if:
Look elsewhere if:
mix-manifest.json.fetchpriority="high"), which requires custom HTML or middleware.For Executives:
"This is a 5-minute fix to cut page load times by 10–30% for high-impact routes. By automatically preloading heavy JavaScript (e.g., analytics, libraries) and prefetching assets for predicted next pages, we’ll improve Core Web Vitals without hiring a frontend engineer. Spatie’s package handles the heavy lifting—just tag assets in our Webpack config, and it generates the optimal <link> tags. Early adopters like [Example Company] saw a 25% drop in bounce rates on product pages after implementing this. The MIT license and zero dependents mean minimal risk."
For Engineering: *"This package solves a common pain point: asset prioritization without manual HTML tweaks. Here’s how we’ll use it:
preload- prefix to critical chunks (e.g., preload-biglibrary.js) in webpack.mix.js to force early loading.prefetch-checkout.css) and trigger them via middleware or Blade directives when users hover over navigation links.@preload in Blade templates. Works seamlessly with our existing Mix setup.
Trade-offs:preload-*).For Design/Systems: *"This won’t change your designs, but it’ll make them load faster. For example:
How can I help you explore Laravel packages today?