• Closed
  • Chris C
    Spectator
    May 26, 2014 at 3:33 am #8439

    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

    Roman
    Spectator
    Posts: 3147
    May 26, 2014 at 5:39 am #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
    Posts: 10
    May 27, 2014 at 10:34 am #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
    Spectator
    Posts: 3147
    May 27, 2014 at 9:23 pm #9858

    probably