JavaScript file count is reasonable
mediumjs_file_count
Checks that the number of JavaScript files is reasonable.
What does this rule check?
Each JavaScript file requires a separate HTTP request. While HTTP/2 mitigates this somewhat, too many files still increase connection overhead and processing time.
Why is this important?
Excessive JavaScript files slow down page load, increase parse/compile time, and can lead to render blocking issues. Bundle your scripts when possible.
How to fix
Bundle JavaScript files using a build tool. Remove unused scripts. Use code splitting for route-based loading.
Examples
Incorrect
<!-- 25 separate script tags -->
<script src="vendor1.js"></script>
<script src="vendor2.js"></script>
...
Correct
<!-- 3 bundled scripts with code splitting -->
<script src="vendor.js" defer></script>
<script src="app.js" defer></script>
Agent fix snippet
Copy this snippet and paste it into your AI coding agent to fix this issue automatically.
Reduce JavaScript file count:
1. Bundle scripts with webpack/Vite/esbuild
2. Use code splitting for route-based loading
3. Remove unused script references
4. Combine small inline scripts