Quick Fix with Thunder
Legacy JavaScript warnings often list dozens of app and vendor scripts that Shopify merchants can't rewrite. Thunder reduces the practical impact by removing non-essential legacy scripts and deferring the ones you keep, so fewer transpiled bundles compete for parsing time during page load.
Use Thunder first to trim the legacy script load, then apply the manual theme fixes below. For broader JavaScript cleanup, pair this with JavaScript optimization and third-party script guides.
Install ThunderWhat Legacy JavaScript Means for Performance
Legacy JavaScript typically refers to ES5 code with polyfills and transformations designed for Internet Explorer and old mobile browsers. Modern browsers can run ES2015+ (ES6+) syntax natively — arrow functions, const/let, classes, modules — without transpilation. When they get ES5 bundles instead, they waste time parsing larger, slower code.
The size difference is significant. A typical modern JavaScript bundle might be 40-60KB smaller than its ES5 equivalent because it skips polyfills for features like Promise, Array.includes, and Object.assign that modern browsers already support. The parsing time difference is even more important because ES5 syntax is more verbose and harder for engines to optimize.
Chrome's legacy JavaScript documentation shows how to serve modern bundles to modern browsers. On Shopify, the challenge is that themes control some JavaScript but apps control the rest, and vendors make their own bundle decisions.
What Shopify Merchants Can and Can't Control
What You Control
- • Theme JavaScript build configuration
- • Browserslist targets for theme assets
- • Module/nomodule patterns in theme.liquid
- • Custom section and snippet JavaScript
- • Which apps you install (choosing modern vendors)
- • App embed loading strategies
What You Don't Control
- • App JavaScript bundle content
- • Vendor script transpilation choices
- • Third-party service polyfill decisions
- • CDN-hosted library versions
- • Payment processor JavaScript
- • Social media widget code
This is why many Shopify stores see legacy JavaScript warnings even after optimizing their theme code. Apps like reviews, chat widgets, analytics tools, and subscription services often ship one bundle for all browsers, choosing compatibility over performance.
Step 1: Audit Which Scripts Trigger the Warning
Run PageSpeed Insights and open the "Avoid serving legacy JavaScript to modern browsers" diagnostic. Group the flagged URLs by domain: your theme assets (cdn.shopify.com), app scripts, and third-party services. Focus optimization effort on theme assets first since those are yours to rewrite.
Look for patterns in the app scripts. If multiple scripts from the same vendor appear, check if that app has updates or alternatives. If old jQuery libraries or polyfill.io bundles appear, those might be removable through theme cleanup rather than app changes.
For context about overall JavaScript load, also review unused JavaScript removal and main-thread work reduction to see if script volume is a bigger issue than legacy syntax.
Step 2: Update Theme Build Configuration
If your theme uses a build process (Webpack, Vite, or similar), check the Browserslist configuration. Many Shopify themes still target IE11 by default, which forces transpilation to ES5 even though IE usage is negligible in 2026:
// Before: .browserslistrc includes old browsers
defaults
IE 11
> 1%
last 2 versions
// After: modern browsers only (95%+ coverage)
> 0.5%
not IE 11
not op_mini all
last 2 versions
Chrome >= 60
Safari >= 11
Firefox >= 55 Check your analytics first. Most Shopify stores see <1% IE traffic in 2026. Update your build targets to match your actual user base rather than supporting browsers that don't exist in your data.
Step 3: Implement Module/Nomodule for Theme JavaScript
The module/nomodule pattern serves modern ES2015+ code to modern browsers and falls back to ES5 for legacy browsers. This gives you compatibility safety with performance benefits for 95%+ of users:
<!-- theme.liquid -->
<!-- Modern bundle for modern browsers -->
<script type="module" src="{{ 'theme.modern.js' | asset_url }}"></script>
<!-- Fallback bundle for IE and old browsers -->
<script nomodule src="{{ 'theme.legacy.js' | asset_url }}"></script> Build both versions from the same source with different targets. Modern browsers get smaller, faster ES2015+ code. Old browsers get the full ES5 bundle with polyfills. The performance difference can be 30-50KB and significantly faster parsing.
// webpack.config.js example
module.exports = [
{
// Modern build
entry: './src/theme.js',
output: {
filename: 'theme.modern.js',
environment: {
module: true,
arrow: true,
const: true,
},
},
target: ['web', 'es2015'],
},
{
// Legacy build
entry: './src/theme.js',
output: {
filename: 'theme.legacy.js',
},
target: ['web', 'es5'],
module: {
rules: [{
test: /.js$/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', {
useBuiltIns: 'usage',
corejs: 3,
}]],
},
},
}],
},
},
]; Step 4: Replace Legacy Dependencies
Older Shopify themes often include jQuery, Lodash, or polyfill libraries that add ES5 overhead. Replace these with modern alternatives or native browser APIs where possible:
// Before: jQuery and polyfills
<script src="https://polyfill.io/v3/polyfill.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
// After: Native APIs for modern browsers
// querySelector instead of $(selector)
document.querySelector('.mobile-nav-toggle')
// fetch instead of $.ajax
fetch('/cart/add.js', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({id: variantId, quantity: 1})
})
// addEventListener instead of $(document).ready()
document.addEventListener('DOMContentLoaded', function() {
// Theme initialization
}); This removes the largest legacy JavaScript dependencies while keeping functionality intact. For complete jQuery migration, see the JavaScript optimization guide for modern alternatives.
Step 5: Choose Apps That Ship Modern JavaScript
When evaluating new apps, check if they mention modern JavaScript support or ES6+ bundles. Well-maintained apps often ship multiple bundles or use dynamic imports to reduce legacy overhead. Apps that haven't updated build configurations in years are more likely to ship large ES5 bundles unnecessarily.
For existing apps, check if settings allow you to disable legacy browser support or reduce polyfill inclusion. Some review, chat, and analytics tools provide configuration options for modern-only mode when they detect your traffic patterns don't require IE support.
See our app speed impact research and apps that slow down your store for guidance on choosing performance-focused app alternatives.
Manual Fix vs Thunder Fix
| Legacy JavaScript source | Manual fix | Thunder fix |
|---|---|---|
| Theme JavaScript with old targets | Update Browserslist config, use module/nomodule pattern | Not applicable — Thunder doesn't rewrite theme build config |
| jQuery and polyfill libraries | Replace with native APIs, remove unnecessary dependencies | Can defer loading of legacy library scripts |
| App scripts with ES5 bundles | Choose apps with modern JavaScript, disable legacy support in settings | Reduces number of legacy app scripts loading |
| Third-party service polyfills | Review each vendor's documentation for modern alternatives | Defers non-critical third-party legacy scripts |
Browser Support and Analytics Review
Before making legacy JavaScript changes, review your store's browser analytics for the last 6 months. Look at Internet Explorer usage, old Android browser versions, and very outdated Safari/Chrome versions. If these represent <2% of your traffic, you can safely serve modern JavaScript to 98%+ of visitors.
For the remaining legacy browser users, provide a functional but simpler experience rather than forcing 98% of users to download slower code. Basic functionality — viewing products, adding to cart, checkout — works fine without complex JavaScript enhancements.
The unminified JavaScript audit often appears alongside legacy JavaScript warnings, indicating general bundle optimization opportunities beyond just ES5 vs modern syntax.
Related JavaScript Optimization Issues
Legacy JavaScript warnings often accompany other script performance problems. Check render-blocking JavaScript, large bundle sizes, and Total Blocking Time warnings that often share the same root causes.
For comprehensive JavaScript cleanup beyond legacy syntax, see the complete Shopify speed optimization guide. For automated script optimization instead of manual bundle rewriting, check Thunder's features or current pricing.
FAQ
What is legacy JavaScript on Shopify?
Legacy JavaScript refers to ES5 code with polyfills and transformations for old browsers like Internet Explorer. Modern browsers (Chrome 60+, Safari 11+, Firefox 55+) can run ES2015+ natively but get slower, larger transpiled bundles instead. This wastes bandwidth and parsing time on 95%+ of real users.
Why do Shopify themes serve legacy JavaScript?
Most Shopify themes and apps build one JavaScript bundle to support all browsers, including IE11. They transpile modern syntax to ES5 and add polyfills for missing features. While this ensures compatibility, it sends unnecessarily large and slow code to modern browsers that don't need it.
Can I control what JavaScript my Shopify store serves?
You control theme JavaScript through build tools and bundler config, but not app JavaScript. Apps are responsible for their own bundles. You can use module/nomodule patterns in custom code and choose apps that ship modern JavaScript, but you can't rewrite vendor scripts.
Does Thunder fix legacy JavaScript automatically?
Thunder can reduce the number of legacy app scripts loading on your store by deferring and removing non-essential ones. However, the specific bundle content (whether it's transpiled ES5 or modern ES2015+) is controlled by the app developer, not by performance optimization tools.
What browsers count as modern vs legacy?
Modern browsers support ES2015+ natively: Chrome 60+, Safari 11+, Firefox 55+, Edge 16+. These represent 95%+ of real traffic. Legacy browsers need transpiled ES5: IE11, very old mobile browsers. Check your analytics, but most stores can safely serve modern JavaScript to the vast majority of visitors.
Should I stop supporting Internet Explorer completely?
Check your store's browser analytics first. IE represents <1% of traffic for most Shopify stores in 2026. If your data confirms low IE usage, you can safely ship modern JavaScript and provide a simple fallback experience for legacy browsers instead of transpiling everything.
Reduce legacy script load, optimize what remains
Thunder automatically removes non-essential app scripts and defers legacy bundles to reduce their impact on modern browsers. Combine with modern theme JavaScript for the best performance.
Install Thunder