I am using a custom WordPress theme that uses AJAX to load pages. As you can imagine this can create an instance where the site loads to a page that does not use Visual Composer (VC) and then part loads another page that does us VC, since the ready load didn’t require the resources.
So far the only solutions I’ve thought of are using VC on every page (that doesn’t work so great for Posts and custom post types) or adding a VC page to the footer (untested).
I looked deeper into the plugins code and found wp_enqueue_script()
is called across many files from what looks to be logic calling the correct extension/add-ons to VC as needed, make perfect sense.
My though is that it would be possible to use PHP to solve this issue, to call just the core requirements of VC, since no galleries or anything special will be used.
Does anyone know how to force VC to load resources to every page or have any experience with this? Thank you!
From what you had said I realised that this needed to be called:
So I ended up adding something like this in functions.php in my template:
WPbakery (authors of VC) explained how to do this.
You have to call a bunch of VC functions in your theme’s function file, but couldn’t say with absolute certainty.
I haven’t tried this method (I’m using Mark Aroni‘s method above, because I don’t need ALL VC stuff on every page, just the CSS/JS), but here’s what they say…