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.
How to use it
Enable it, then test the front end
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.
defer on every enqueued front-end script tag except jQuery.jquery, jquery-core and jquery-migrate handles), everything in wp-admin, and tags that already have defer.Compatibility
Vectro detects these and steps aside
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.