Elementor and cloudflare


#1

Rocketloader doesn’t seem to play nicely with elementor and breaks the editor from loading.

I found a guide on elementor that says to enter a line of code but to prevent compatibility issues in the future (the current workaround is disabling rocketloader everytime).

So to save time, I would like to enter the code but I have no idea what file this should be entered in.

Here is the guide https://docs.elementor.com/article/360-elementor-cloudflare-rocket-loader

and this is the code,

<?php add_filter( 'script_loader_tag', function( $tag, $handle ) { if ( isset( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] ) { return str_replace( ' src', ' data-cfasync="false" src', $tag ); } return $tag; }, 10, 2 ); any help would be greatly appreciated. Thank you, -Dean

#2

I’m on my way out, but my first guess is the snippet should go at the end of your theme’s functions.php file. Don’t include that php part. The snippet should begin with add_filter and end with the semicolon.


#3

Thank you sdayman, I’ll try it out.


#4

Did that work? I also have Elementor on one of my sites and ended up disabling Rocket Loader.


#5

No, this did not work for me although when it comes to editing code I really don’t know what I am doing. Here is a screenshot of where I added the code.

Also, I got this from Cloudflare but I also don’t know where I would enter this.