If your NMI card fields vanish or freeze after you turn on WP Rocket, LiteSpeed Cache or a similar optimizer, exclude the NMI Collect.js script and your payment plugin’s scripts from JavaScript delay, defer, combine and minify, then exclude the checkout pages from page caching. That is the fix in most cases. NMI’s own documentation does not name optimizer plugins, so treat this as general troubleshooting advice, not an NMI-documented rule. Below is the order to work in.
Why optimizers break hosted card fields
With the Collect.js hosted fields, the card number, expiry and CVV live in iframes served from NMI. The page loads a script from secure.nmi.com, and that script builds the iframes when the checkout is ready. Anything that changes when or how that script runs can leave you with an empty box.
- Delay JavaScript: holds scripts until the first click, scroll or keypress. The fields never appear because the script has not run.
- Combine or minify: rewrites file order or merges scripts, which can break scripts that expect jQuery or a checkout event to exist first.
- Page caching: serves a stale checkout page with an old nonce or token, so the order fails after the customer clicks Pay.
- Cloudflare Rocket Loader or similar: reorders script execution at the edge.
Step 1: find what is actually loading
- Open your checkout in a private window while logged out.
- View the page source and search for
nmi. Note every script URL that contains it, including the Collect.js URL and your payment plugin’s own files. - Open browser developer tools, Network tab, and reload. Confirm Collect.js returns a 200 and the card field iframes appear.
You need those URLs for the exclusion lists below. If the fields are blank even with the script loading, see the payment method not showing guide first, because the cause may be a plugin conflict and not an optimizer.
Step 2: exclude the scripts
Exact menu names change between versions, so match these to your current screens.
- WP Rocket: under File Optimization, add the NMI script patterns to the exclusion boxes for Delay JavaScript execution, Minify JavaScript and Combine JavaScript files. A pattern like
secure.nmi.complus your gateway plugin folder name usually covers both. - LiteSpeed Cache: under Page Optimization, JS Settings, add the same patterns to the JS excludes and to the deferred and delayed excludes. If you use Combine or Delayed Includes, test with them switched off first.
- Cloudflare Rocket Loader: turn it off for your checkout URLs with a page rule or configuration rule, or disable it for the whole zone if you cannot target by path.
Exclude the smallest set that works. If you cannot tell which script matters, switch one optimizer option off at a time, clear caches, and retest the checkout.
Step 3: keep checkout out of the page cache
Cart, checkout and My Account pages must never be served from a static cache. Most WooCommerce-aware optimizers exclude them by default, but confirm it in your settings. If you use a custom checkout URL or a page-builder checkout, add that path to the never-cache list yourself. The builder checkout guide covers the common custom-URL cases.
Also check that cookies set for the cart and session are respected by any CDN or server-level cache in front of WordPress.
Step 4: clear everything and retest
- Purge the plugin cache, any CDN cache and any server cache.
- If the optimizer generates a critical CSS or used-CSS file, regenerate it.
- Place a test order in sandbox mode, covering a fresh visit with no interaction before clicking the card field.
- Test on a phone, since delay options often behave differently on mobile.
The first-interaction test matters. A delayed script can work fine once you have scrolled, then fail for a customer who goes straight to the card field.
Do not trade speed for broken payments
Checkout is the page where an optimizer saves you the least and can cost you the most. If a setting buys a few milliseconds but breaks the field in one browser, leave it off for checkout. For where the real delays come from, read what actually slows a WooCommerce checkout down.
If you accept bank payments, the same exclusions apply to the account and routing fields. ACH and eCheck checkout is a Pro feature and uses the same hosted-field approach, so one exclusion list covers both. The NMI for WooCommerce plugin itself is free on WordPress.org. Still stuck after these steps: send your page source and a console screenshot to support, and check the compatibility hub for related fixes.
Last reviewed November 2026.