Performance module Free feature

Defer JavaScript

Adds the defer attribute to front-end script tags, except jQuery, so the browser can finish building the page before it runs them.

What it does

Lets the page draw before the scripts run

Defer JavaScript is a Vectro performance feature that adds the defer attribute to every enqueued front-end script except jQuery, allowing the browser to finish parsing your HTML before executing them and reducing render-blocking time.

By default a script tag stops HTML parsing. The browser reaches it, downloads the file, executes it, and only then continues building the page. Every script in your head is a pause before anything appears on screen.

The defer attribute changes that. The browser downloads the script alongside parsing and runs it once the document is complete. This feature adds defer to every script WordPress prints through its enqueue system on the front end, apart from jQuery.

jQuery is excluded automatically, because a great many WordPress plugins assume it is already available. wp-admin is never touched, and scripts that already carry defer are left as they are. Scripts marked async are not skipped, so they end up with both attributes, and browsers then treat them as async.

Why it matters

Render blocking is what makes a page feel slow

Largest Contentful Paint is the Core Web Vitals metric most sites fail, and render-blocking JavaScript is one of the most common causes. A theme and a handful of plugins can easily queue eight or ten scripts, each one a stop in the parse before a visitor sees anything at all.

Deferring them does not make the files smaller or fewer. It changes when they run, so the browser can paint content first and execute behaviour second. On a typical WordPress site that reordering is worth a meaningful improvement in perceived load time for no change to the code itself.

Content paints sooner
The browser finishes the HTML before running deferred scripts, so something appears on screen earlier.
jQuery excluded automatically
Too many plugins assume jQuery is loaded synchronously, so Vectro never defers it.
Admin scripts untouched
Only front-end scripts are deferred. wp-admin behaves exactly as before.
Already deferred scripts left alone
Scripts that already carry defer are not changed.

How to use it

Enable it, then test the front end

1
Open the Performance module
Go to Vectro > Performance in wp-admin.
2
Toggle Defer JavaScript on
Every front-end script except jQuery starts receiving the defer attribute.
3
Save Performance Settings and clear your caches
Purge any page cache and CDN cache so visitors receive the updated markup rather than a cached copy.
4
Test every interactive part of your site
Sliders, menus, popups, forms and anything that runs on page load are what break if a script depended on running early.
5
Turn it off if something breaks
If an interactive element stops working, disable the toggle. A broken slider costs more than the render-blocking time it saved.

Technical detail

Where the attribute is added

Vectro filters the script tag output that WordPress generates for enqueued scripts and adds defer to every tag except jQuery’s and tags that already have it. Because it works on the enqueue system, scripts that a theme or plugin hardcodes directly into a template are not covered.

Deferred scripts execute in document order once parsing completes, so relative ordering between deferred scripts is preserved. What changes is their position relative to the parser and to any inline script that is not deferred – which is the usual source of breakage.

Attribute added
defer on every enqueued front-end script tag except jQuery.
Excluded
jQuery (the jquery, jquery-core and jquery-migrate handles), everything in wp-admin, and tags that already have defer.
Scope
Scripts registered through the WordPress enqueue system.
Not covered
Scripts hardcoded directly into theme or plugin templates.
Execution order
Deferred scripts still run in document order, after parsing completes.
Common breakage
Inline scripts that expect a deferred file to have run already.

Compatibility

Vectro detects these and steps aside

WP Rocket
Vectro defers to WP Rocket, which has its own JavaScript loading controls.
Autoptimize
Vectro disables its own defer so the two do not both rewrite script tags.
LiteSpeed Cache
Vectro switches its own defer off while LiteSpeed Cache is active.
W3 Total Cache
Vectro defers to W3 Total Cache minify and defer settings.
Perfmatters
Vectro disables its own defer in favour of the Perfmatters script manager.
Asset CleanUp
Vectro steps aside so Asset CleanUp keeps sole control of script handling.

You can override any automatic deferral from the Compatibility panel in Vectro’s dashboard if you would rather Vectro handle it.

Questions

Frequently asked

What does defer JavaScript do in Vectro?

Defer JavaScript adds the defer attribute to every enqueued front-end script tag except jQuery, so the browser finishes parsing your HTML before executing them. This reduces render-blocking time and lets page content appear sooner.

Does Vectro defer JavaScript work with WP Rocket?

No – if WP Rocket is active, Vectro detects it and disables its own defer feature automatically. WP Rocket has its own JavaScript loading controls and handles it instead, so script tags are never rewritten twice.

How do I defer JavaScript in Vectro?

Go to Vectro > Performance in wp-admin, toggle Defer JavaScript on, then clear your page cache and CDN cache. Test every interactive element on your site afterwards, because scripts that expected to run early can break.

Is defer JavaScript in Vectro free or Pro?

Yes, Defer JavaScript is free. It is included in the free Vectro plugin on WordPress.org with no account required.

Will deferring JavaScript break my WordPress theme?

It can, if a script or inline snippet expects a deferred file to have already executed. Vectro excludes jQuery and admin scripts automatically to reduce that risk, and you can turn the feature off immediately if something stops working.

Related features

Trim the front-end payload

Vectro Pro adds HTML, CSS and JS minification for additional page weight reduction. See Pro plans

Download Vectro free on WordPress.org

27 features across Security, Performance and Maintenance. No account required, no expiry, unlimited sites.

Scroll to Top