Rocket Loader Issue with Preloader Script

Hello,
i use the following script in my WP functions.php to display a Preloader.gif.

// Preloader Code Header
add_action(‘wp_head’, ‘dp_preloader’);
function dp_preloader() {
?>


 



.dp_preloader {position: fixed;top: 0;left: 0;right: 0;bottom: 0;background-color: #ffffff;z-index: 999999;height: 100%;width: 100%;overflow: hidden !important;}
.dp_preloader .dp_loader_icon {position: absolute;left: 50%;top: 50%;background-repeat: no-repeat;background-position: center;-webkit-background-size: cover;background-size: cover;background-image: url(<?php echo get_stylesheet_directory_uri();?>/img/preloader.gif);width: 64px;height: 64px;margin: 0px 0 0 -30px;}

<?php } // Preloader Code Footer add_action('wp_footer', 'dp_preloader_css'); function dp_preloader_css() { ?>
<script type="text/javascript">
	jQuery(window).load(function(){	
		jQuery('.dp_loader_icon').fadeOut('fast'); 
		jQuery('.dp_preloader').delay(0).fadeOut('fast'); 
	})
</script>
<?php } When Rocket Loader is activated, the .gif is shown, but permanent. i get the following error in console: ![rocket_loader_issue|690x109](upload://4aGKfjvGGPCHLOEUhTsDr25YQPx.jpeg) Uncaught Type Error e.indexOf is not a function When Rocket Loader is disabled the Preloader Script works fine. Does anyone know, how to get the Script with Rocket Loader working? Do i have to adapt something? Thx br

I tried already with script data-cfasync=“false” type=“text/javascript” , but still the rocket loader seems not to ignore the jquery script

But does that action load up after the default WordPress jQuery resource load?
Moreover, is the WordPress version actually including and loading an jQuery as a resource or you have to use Migrate jQuery helper plugin to load jQuery?

Have you tried disabling the Rocket Loader in Cloudflare dashboard and Purging the cache at Cloudflare?
Any difference?

1 Like

thanks for your reply. actual wp version installed, jQuery migrate 3.3.2 is loaded.
tried yet again to disable rocket loader, cleared all caches, still the issue. preloader is shown, but after resources loaded not closing. seems there is an issue with jQuery of the script.
thx

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.