• Creator
    Topic
  • #8439

    Chris C
    Spectator
    Been thanked: 0 times

    I’m at Theme Options’ “add code to space before the </body> tag”.

    I’m trying to add a piece of javascript:

    <script data-cfasync=”false”>
    $(window).scroll(function() {
    $(‘#wrapper’).each(function(){
    var imagePos = $(this).offset().top;

    var topOfWindow = $(window).scrollTop();
    if (imagePos < topOfWindow+400) {
    $(this).addClass(“divFadeIn”);
    }
    });
    });
    </script>

    However after I refresh the page (cleared cache, Cloudflare in development mode, etc.), the javascript doesn’t get added.

    I tested with some other html script: e.g. <div>test</div> and again nothing got added.

    Is it broken?

    Chris

Viewing 3 replies - 1 through 3 (of 3 total)
Replies
  • Roman
    Keymaster
    Post count: 2543
    Been thanked: 29 times
    #9848 |

    weird…for me it works…also should define the script as text/javascript:

    Code:
    <script type=”text/javascript” data-cfasync=”false”>
    $(window).scroll(function() {
    $(‘#wrapper’).each(function(){
    var imagePos = $(this).offset().top;

    var topOfWindow = $(window).scrollTop();
    if (imagePos < topOfWindow+400) {
    $(this).addClass(“divFadeIn”);
    }
    });
    });
    </script>

    Chris C
    Spectator
    Post count: 10
    Been thanked: 0 times
    #9850 |

    Thanks for the quick response.

    I turned off CloudFlare’s Rocket feature and it worked. Seems that Rocket could still mess things up even if you add the data-cfasync=”false” tag.

    Roman
    Keymaster
    Post count: 2543
    Been thanked: 29 times
    #9858 |

    probably

Viewing 3 replies - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.