JavaScript Optimization
Defer, delay, and minify JavaScript with 28+ quick exclusion presets and per-page disable controls.
Last updated Feb 21, 2026
Overview
JavaScript is render-blocking by default. When a browser encounters a <script> tag, it stops parsing HTML, downloads the script, executes it, then resumes. BoostPro offers three strategies to reduce JavaScript's impact on page load: defer, delay, and minify.
All JavaScript optimization settings are located on the BoostPro → Advanced tab under the JavaScript Processing section.
Defer JavaScript
Adds the defer attribute to script tags. Deferred scripts download in parallel with HTML parsing but wait to execute until the HTML is fully parsed. Scripts still execute in their original order.
- Default: Off
- Badge: Advanced
- Impact: Reduces render-blocking, improves First Contentful Paint (FCP)
Auto-excluded scripts
BoostPro never defers these scripts to prevent breakage:
jquery,jquery-core,jquery-migratewp-polyfill,wp-hooks- Scripts that already have
deferorasync - Inline scripts (no
srcattribute) - Module scripts (
type="module")
Custom exclusions
If a specific script breaks when deferred, add its handle or URL pattern to the exclusion list, one per line:
slider-script
my-custom-plugin
analytics.jsDelay JavaScript
More aggressive than defer. Delayed scripts do not load at all until the user interacts with the page (scroll, click, tap, mousemove, or keypress). A 10-second fallback timer ensures bots and non-interactive sessions can still execute scripts.
- Default: Off
- Badge: Advanced
- Impact: Dramatic improvement to LCP, FID, and TBT scores
Auto-excluded from delay
- Scripts with
type="module",type="importmap", ortype="speculationrules" - JSON data scripts (
application/json,application/ld+json) - Scripts with the
data-boost-no-deferattribute
Delay modes
BoostPro supports two delay modes:
- Exclusion mode (default): All scripts are delayed except those matching your exclusion patterns. Best for most sites where you want maximum performance and selectively protect critical scripts.
- Inclusion mode: Only scripts matching your inclusion patterns are delayed. Everything else loads normally. Best when you want precise control and only want to delay specific heavy scripts.
Quick exclusion presets
BoostPro includes 28+ pre-configured patterns for popular services. Instead of manually figuring out which patterns to exclude, toggle presets for common tools:
- Google Analytics, Google Tag Manager, Google Ads
- Google reCAPTCHA, Google Maps
- Facebook Pixel, Meta SDK
- HubSpot, Hotjar, Intercom, Drift
- And many more
Each preset adds the correct exclusion patterns automatically.
Important
Delay JavaScript can break features that need to run on page load: sliders, analytics tracking, consent managers, and form validation. Use the exclusion presets for known services and test thoroughly.
Minify JavaScript
Removes whitespace and comments from JavaScript files to reduce their size. The lowest-risk optimization of the three.
- Default: Off
- Badge: Advanced
- Skips: Files already minified (
.min.js) and external scripts - Smart caching: Only serves the minified version if it is at least 10% smaller than the original
- Cache location:
/wp-content/cache/boost-js/(100MB limit, 30-day cleanup)
Custom exclusions
If a script has issues when minified, add its handle or URL pattern to the exclusion list:
my-custom-script
plugin-problematic-jsDefer vs. delay vs. minify
| Feature | Defer | Delay | Minify |
|---|---|---|---|
| What it does | Moves execution after HTML parsing | Delays execution until user interaction | Reduces file size by removing whitespace/comments |
| Risk level | Medium | High | Low |
| Performance impact | Moderate (faster render) | Significant (faster render + lower TBT) | Moderate (smaller downloads) |
| When to use | Most sites, after testing | Sites focused on Core Web Vitals | All sites (safe starting point) |
Developer attribute
Add the data-boost-no-defer attribute to any script tag to exclude it from both defer and delay processing:
<script src="critical.js" data-boost-no-defer></script>BoostPro will skip this script entirely.
Per-page disable
Defer, delay, and minify can each be disabled for specific pages via the Resource Manager. This is useful for pages with known script compatibility issues.
Tip
Start with minify (lowest risk), then add defer, then delay. Test each change before adding the next. Run PageSpeed tests after each change to measure the improvement.