• Hi

    Thanks for this awesome plugin. When i activate rocket loader in cloudflare then the images load after 8-10seconds and many times they don’t load at all so i want to exclude lazy load javascript from it. I saw on cloudflare website that to exclude certain javascripts i should add <script data-cfasync=”false” src=”/javascript.js”></script> before the script. My question is where should i add this code to exclude this plugins’ script?

    Regards
    Vaibhav

    https://www.ads-software.com/plugins/bj-lazy-load/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter vaibhavbthl

    (@vaibhavbthl)

    Hi

    Can anyone help me with this issue. I also emailed cloudflare and got the following response – You would need to speak with the author of that particular plugin. Normally it will be an edit in one of the PHP files that the plugin uses.
    Any help is appreciated.

    Regards
    Vaibhav

    I have the same problem with Cloudflare.. my “tooltips” are showing my placeholder image. The rest of my content loads fine though.

    Are you having problems with “all” images? If so, try choosing “no” for
    1.) Load hiDPI (retina) images
    and
    2.) Load responsive images

    In the meantime, I’m very interested in how to get my tooltip images working with Cloudflare and BJ Lazy Load too, and excited that you have got further than I have with troubleshooting, so I’ll have a look and see where I might put that code and update if I find the right bit ??

    I thought it was the same problem, but we have different problems. I’m not using RocketLoader.

    Here is a detailed answer on how to do what you want though:

    https://wordpress.stackexchange.com/questions/50457/how-do-i-add-custom-attributes-to-javascript-tags-in-wordpress/90156#90156

    You add the code in your theme’s function.php

    The only problem with that code though, is that it seems you have to add a list of all the .js files you want to optimize? But maybe it will work if you just add what you don’t want to optimize…

    So if I was using Rocket Loader, I would first be trying something like this in my themes function.php:

    function rocket_loader_attributes( $url )
    {
        $ignore = array (
             'https://mydomain.com/wp-content/plugins/bj-lazy-load/js/combined.min.js',
        );
        if ( in_array( $url, $ignore ) )
        { // this will be ignored
            return "$url' data-cfasync='false";
        }
    
        return $url;
    }
    add_filter( 'clean_url', 'rocket_loader_attributes', 11, 1 );

    But if that doesn’t work, then you might have to add the full script at that url, with all the js files you want to optimize, which sounds like too much drama.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem with Cloudflare’ is closed to new replies.