• jcbsep

    (@jcbsep)


    Hi!

    My problem is the following:

    When I activate Cloudflare’s Rocket Loader, replies to comment stop working.

    It’s a general problem, as I’ve doublechecked this in different themes.

    After reading the proper documentation, I know I need to set CF’s Rocket Loader to ignore those javascript that don’t work properly with it using the following general script:

    <script data-cfasync=?false? src=?javascript.js?></script>

    I also know (or at least think) that the .js I need CF to ignore (in order to comments reply to work) is the following:

    comment-reply.min.js

    The question is:

    Where in WordPress should I paste this: <script data-cfasync=?false? src=?comment-reply.min.js?></script> ?

    Thanks in advance.

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • JNashHawkins

    (@jnashhawkins)

    I imagine that’s intended to modify or replace the present javascript call so find the call in your header or footer PHP files in the theme you are using.

    Thread Starter jcbsep

    (@jcbsep)

    Hi @jnashhawkins

    Exactly, but that’s where I need help with.

    JNashHawkins

    (@jnashhawkins)

    Do you have the Theme editor under your ‘themes’ in the dashboard?

    Else FTP in or use your web host’s file manager if they offer one.

    Thread Starter jcbsep

    (@jcbsep)

    I have access both ways.

    The problem is still to find that call, and more important, display it as:

    <script data-cfasync=”false” src=”comment-reply.min.js”></script>

    Although I find the proper call (task 1), I need to find the way to wrap it like in the example above (task 2).

    Why am I saying this? Because I won’t find a <script> calling this comment-reply.min.js, as WordPress generates these scripts automatically with a function like wp_enqueue_script. So, although I find the call I still need to know a way to wrap it as the code above.

    Hello,

    I’m not sure if it will work, but first you might want to check row 190 in the functions.php file, then this stackoverflow question:
    https://stackoverflow.com/questions/42888357/how-to-bypass-cloudflare-rocket-script-if-wp-enqueue-script-is-used-to-add-scrip

    Kind Regards, Roman.

    Thread Starter jcbsep

    (@jcbsep)

    Thanks @romanbon , but for some reason it doesn’t work for me. :/

    Well, you can try to contact Cloudflare support and see what they say.

    Kind Regards, Roman.

    this is work 100% i just try it

    function mixtheme_add_data_attribute( $tag, $handle, $src ) {
        if ( 'comment-reply' !== $handle )
           return $tag;
    
        return str_replace( ' src', ' data-cfasync="false" src', $tag );
    }
    
    add_filter( 'script_loader_tag', 'mixtheme_add_data_attribute', 10, 3 );
    
    
    ZLC

    (@kindnessville)

    THANK YOU @alexmarinos! You just saved the day for me! Many, many thanks!

    Thread Starter jcbsep

    (@jcbsep)

    Hey @alexmarinos , thanks for the help and sorry for the late reply.

    Where did you paste that code?

    @jcbsep

    I pasted the code (from @alexmarinos) in my functions.php (child!) workes like charme!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Cloudflare’s Rocket Loader and comments reply issue’ is closed to new replies.