Load Visual Composer on Every Page (AJAX Setup)

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:

wp_enqueue_script( 'wpb_composer_front_js' );
wp_enqueue_style( 'js_composer_front' );
wp_enqueue_style( 'js_composer_custom_css' );

So I ended up adding something like this in functions.php in my template:

add_action( 'wp_enqueue_scripts', 'add_theme_stylesheet' );

function add_theme_stylesheet() {
    wp_enqueue_script( 'wpb_composer_front_js' );
    wp_enqueue_style( 'js_composer_front' );
    wp_enqueue_style( 'js_composer_custom_css' );

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...


Need Your Help

How to append '\\?\' to the front of a file path in Python

python filepath backslash

I'm trying to work with some long file paths (Windows) in Python and have come across some problems. After reading the question here, it looks as though I need to append '\\?\' to the front of my ...