P1Issue #55
Avoid serving legacy javascript to modern browsers
β What does it mean?
β What does it mean?
Legacy JavaScript refers to older JavaScript syntax and polyfills that were originally created for compatibility with outdated browsers (like IE11).
Modern browsers (Chrome, Edge, Safari, Firefox) already support ES6+ features, so serving legacy bundles increases page weight and execution time unnecessarily.
π¨ Why is it important for SEO?
π¨ Why is this a problem for SEO & Performance?
Slower Page Load β Extra polyfills and transpiled code increase JavaScript bundle size.
Higher Parse & Execution Time β Browsers spend more time processing unused legacy code.
Worse Core Web Vitals β Especially INP (Interaction to Next Paint) and FCP (First Contentful Paint).
Indirect SEO Impact β Google prioritizes faster, more efficient sites in rankings.
β How to Fix It
β
Best Practices to Fix
Use differential serving:
Serve modern ES6+ bundles to modern browsers.
Serve legacy transpiled bundles only to old browsers.
Tools/Strategies:
Configure <script type="module"> for modern code and <script nomodule> for legacy fallback.
Use build tools like Webpack, Rollup, or Next.js to generate dual bundles (modern + legacy).
Audit polyfillsβremove unnecessary ones when targeting modern browsers.
β Bad Example
π Example
β Bad (Legacy JS served to all browsers):
<script src="/static/js/bundle-legacy.js"></script>
π Even Chrome/Edge users get the heavy legacy bundle.
β Good Example
β
Good (Differential Serving with Modern + Legacy fallback):
<!-- Modern bundle for modern browsers -->
<script type="module" src="/static/js/bundle-modern.js"></script>
<!-- Legacy bundle only for old browsers -->
<script nomodule src="/static/js/bundle-legacy.js"></script>
π Modern browsers load lightweight modern JS.
π Old browsers still have a fallback.
β‘ Result
β‘ SEO & UX Impact of Fixing
Reduced JavaScript size β Faster load times.
Improved Core Web Vitals (FCP, INP, TBT).
Better Crawl Efficiency β Googlebot (which runs modern Chromium) loads modern bundles faster.
Higher Rankings β Speed boosts contribute to SEO performance.