Overview
Some time ago I was working on a client's site who was complaining about site performance. The pages were taking a very long time to open. The cache helped to some extent to solve this problem, but after clearing it the first page loading was still very long (up to 60 seconds).
While looking into the problem, I noticed that the site uses Elementor page builder with many add-ons. All this stuff really increased loading time: a lot of css and js files, query loops, complex markup.
I decided to test how fast the site would run without Elementor. I decided to create a new page which will be just filled with test information and will not be made in Elementor. In fact, the page should not load any Elementor related resources.
And this is where the problem arose - how to do it. How can I create a page on a site that's made entirely in Elementor that won't be connected to it in any way?
I finally found a solution and am sharing it with you below.
Why to do this?
As I said before, I needed to create an Elementor independent page to test the loading speed and understand its impact on overall performance.
You may also want to switch from Elementor to another page builder over time. That way you can make the transition gradual and seamless.
How
It's very simple - you just need to use the code below to completely disable Elementor on certain pages.
add_filter( 'elementor/documents/get/post_id', 'elementor_disable_page', 999 );
function elementor_disable_page( $post_id ) {
global $post;
if ( $post && $post->ID == 9855 ) {
$post_id = 0;
}
return $post_id;
}
In this example, we disabled Elementor on the page with ID = 9855. Specify any other value you need here.
You can also use any other conditions for the pages. For example - we want to disable Elementor for all blog posts. In this case we just use the following code:
add_filter( 'elementor/documents/get/post_id', 'elementor_disable_page', 999 );
function elementor_disable_page( $post_id ) {
global $post;
if ( $post && is_singular('post') ) {
$post_id = 0;
}
return $post_id;
}