Force enqueue Elementor scripts and styles on AJAX site
-
Hi there,
Since my site’s page content is loaded via AJAX
wp_head()
is only executed on the first page load and Elementor’s assets are sometimes not enqueued when needed, since not all pages use Elementor.Best thing I can think of is to make sure Elementor scripts and styles are enqueued on every page load, or ideally conditionally on pages I know will need them.
This seems to work: I add the following to the wp_enqueue_scripts hook.
$elementorFrontend = new \Elementor\Frontend(); $elementorFrontend->enqueue_scripts(); $elementorFrontend->enqueue_styles();
Is this future proof? Is there a better way of doing this?
Many thanks,
Simon
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Force enqueue Elementor scripts and styles on AJAX site’ is closed to new replies.