← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

JavaScript Bundling — Vite, Webpack, esbuild

javascript ES2015 Intermediate

Also Known As

Vite Webpack esbuild bundler Laravel Mix Laravel Vite

TL;DR

Bundlers combine JS modules into optimised files served by PHP — Vite for dev speed, Webpack for complex pipelines, esbuild for raw performance.

Explanation

PHP serves static assets (JS, CSS) either directly or via a bundler output. Vite (Rollup-based): instant dev server with HMR, fast production builds — recommended for new projects. Webpack: mature, rich plugin ecosystem, complex config — used in Laravel Mix. esbuild: Go-based, 10-100x faster than Webpack, minimal config. Laravel Vite plugin: integrates Vite with PHP's asset manifests. Bun: JS runtime + bundler. All output a manifest.json (or similar) mapping source files to hashed production filenames PHP uses.

Common Misconception

PHP can serve unbundled JavaScript module files directly in production — browsers require many HTTP/2 requests for unbundled ES modules; a bundler reduces this to a few optimised files with tree-shaking and minification.

Why It Matters

PHP projects using modern JavaScript need a bundler to produce optimised assets — understanding Vite's asset manifest lets PHP correctly reference hashed filenames for cache-busting.

Common Mistakes

  • Serving unbundled node_modules in production
  • Not using the asset manifest for PHP template references
  • Committing dist/ folder to git instead of building in CI

Code Examples

✗ Vulnerable
<!-- Referencing src file directly — no cache busting, no minification: -->
<script src="/resources/js/app.js"></script>
✓ Fixed
<!-- Vite manifest.json: {"resources/js/app.js": {"file": "assets/app.Abc123.js"}} -->

<!-- PHP reads manifest for hashed filename: -->
<?php
$manifest = json_decode(file_get_contents(public_path('build/manifest.json')), true);
$appJs = $manifest['resources/js/app.js']['file'];
?>
<script src="/build/<?= $appJs ?>" type="module"></script>
<!-- Or use Laravel's @vite('resources/js/app.js') directive -->

Added 17 Mar 2026
Edited 22 Mar 2026
Views 29
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 2 pings T 0 pings F 0 pings S 1 ping S 1 ping M 0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 1 ping T 0 pings W 2 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 2 pings T
Amazonbot 1
Amazonbot 9 Perplexity 5 SEMrush 3 Unknown AI 2 Google 2 Ahrefs 2 Majestic 1
crawler 23 crawler_json 1
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Use Laravel's @vite() directive or read the Vite manifest.json in PHP to reference correctly hashed asset filenames
📦 Applies To
javascript ES2015 web laravel
🔗 Prerequisites
🔍 Detection Hints
PHP templates hardcoding JS filenames without reading asset manifest; node_modules referenced directly in production HTML
Auto-detectable: ✗ No lighthouse webpack-bundle-analyzer
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: Medium ✗ Manual fix Fix: Medium Context: File

✓ schema.org compliant