# Defer & Delay JavaScript for WordPress

> Stop scripts from blocking page rendering by deferring them, or delaying them until the visitor interacts. Test your key pages (menus, sliders, forms, cookie…

TW-PRF-05 Performance


Stop scripts from blocking page rendering by deferring them, or delaying them until the visitor interacts. Test your key pages (menus, sliders, forms, cookie banners) after switching it on.

[Get it from $26 a year](https://togglework.app/pricing/#plans) [Try it in the demo](https://togglework.app/demo/)

Defer & Delay JavaScript

**Part number**
: TW-PRF-05
**Section**
: [Performance](https://togglework.app/features/performance/)
**Settings**
: 6 (3 on/off)
**Starts**
: Switched off
**In plans**
: Every plan

## Why it matters

When a browser meets a normal script tag, it stops building the page until that script has downloaded and run. A theme and a dozen plugins can add enough scripts to hold up the first paint by seconds on a phone, and keep the page from responding to taps while they run.

Deferring lets the page render first and runs scripts after. Delaying goes further and waits for the visitor’s first interaction.

### What it does

- Defer mode: scripts download in parallel and run after the HTML is parsed. Safe for most sites.
- Delay mode: scripts wait for the first mouse move, scroll, tap or key press, with a timeout (default 10 seconds).
- Keeps jQuery loading normally by default, because many themes use it inline.
- Exclusions by script handle or URL; excluded scripts and their dependencies load normally.

![Defer & Delay JavaScript settings screen in the Toggleworks WordPress plugin, showing Mode, Never defer or delay jQuery, Exclusions, Delay timeout (seconds)](https://togglework.app/wp-content/themes/toggleworks-site/assets/img/parts/performance-defer-scripts.webp?v=1795524211)

The Defer & Delay JavaScript screen in wp-admin, where you switch it on and change its settings.

## Set it up

1. Switch it on in **Defer** mode.
2. Click through your key pages: menus, sliders, forms, cookie banner, cart and checkout.
3. If something stops working, add its script to the exclusions. Only try Delay mode once Defer works everywhere.

## What you can set

Switch Defer & Delay JavaScript on in Toggleworks → Performance, then adjust any of these. Each one starts with a default, so you can switch the part on first and fine-tune later.

- Mode
- Never defer or delay jQuery
- Exclusions
- Delay timeout (seconds)
- Fire DOMContentLoaded and load again after delayed scripts run
- Don't apply for logged-in users

## Good to know

- Delay mode gives the best lab scores but anything that must run straight away (a slider at the top, a cookie banner) needs excluding.
- Never set the delay timeout to 0 on a live site: scripts would wait forever for a visitor who never scrolls.

[Guide: How to speed up a WordPress site, in the right order](https://togglework.app/guides/speed-up-wordpress/)

## One less plugin to install

Defer & Delay JavaScript does a job people often install a separate plugin for:

- Deferring and delaying JavaScriptOften done with WP Rocket
- Deferring and delaying JavaScriptOften done with Perfmatters

## Comes with 187 more parts

Defer & Delay JavaScript is one part of Toggleworks, a single plugin for security, speed, SEO, backups, email and store tools. Switch on what your site needs; the rest stays off and loads nothing.

[All 18 Performance parts](https://togglework.app/features/performance/)

### People also look for it as

- defer
- delay
- async
- javascript
- render blocking
- tbt
- interaction
- core web vitals
- scripts

## Often switched on with it

- [Critical CSS](https://togglework.app/features/performance/critical-css/) — TW-PRF-03 · Inlines only the CSS needed for the top of each page and loads the rest without blocking — fixing the “eliminate render-blocking… · 5 settings
- [Asset Manager](https://togglework.app/features/performance/asset-manager/) — TW-PRF-01 · See every CSS and JavaScript file a page loads and switch off the ones it does not need — on one page, everywhere, or everywhere… · Own screen in wp-admin
- [Lazy Load](https://togglework.app/features/performance/lazy-load/) — TW-PRF-11 · Lazy load images and iframes across the whole page while keeping the first images eager for a fast LCP. Optional click-to-play… · 14 settings
- [Code Snippets](https://togglework.app/features/core/code-snippets/) — TW-COR-03 · Add PHP, CSS, JavaScript and HTML snippets without editing theme files — with conditions, revision history and automatic shut-off… · Own screen in wp-admin
- [Header & Footer Code](https://togglework.app/features/core/header-footer-code/) — TW-COR-12 · Add analytics tags, pixels, meta tags or custom CSS to every page without editing the theme. · 5 settings
- [WooCommerce Speed](https://togglework.app/features/woocommerce/woo-performance/) — TW-WOO-35 · Stop WooCommerce scripts, styles and cart fragments loading on blog posts and pages, and turn off admin marketing extras. · 7 settings

## Questions

**Is Defer & Delay JavaScript included in every Toggleworks plan?**

Yes. Every plan includes all 188 parts, Defer & Delay JavaScript among them. Plans differ only in how many sites you can use them on, and staging or local copies of a site don’t count.

**Does Defer & Delay JavaScript slow my site down when it’s switched off?**

No. Every part starts switched off, and a part that is off loads none of its code. Switch on Defer & Delay JavaScript only if your site needs it.

**What if a setting locks me out?**

Add `define( 'TOGGLEWORKS_SAFE_MODE', true );` to wp-config.php. It pauses every part until you remove the line, and Tools → Recent changes lets you undo a change.

**Can I try Defer & Delay JavaScript before I buy?**

Yes. The [live demo](https://togglework.app/demo/) runs a WordPress site with Toggleworks in your browser, and every plan has a 14-day refund.

## Switch off the plugin pile.

All 188 parts, one license, updates and support. 14-day refund.

[Choose a plan](https://togglework.app/pricing/#plans) [Try the live demo](https://togglework.app/demo/)

---

Source: https://togglework.app/features/performance/defer-scripts/
