Same script includes behaving in different ways on two pages(lazy load not working), help!

I have these includes on two pages for lazy loading:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.9/jquery.lazy.js"></script>

<script>
    $(function() {
        $('.lazy').lazy();
    });
</script>

One on https://www.goodfreephotos.com and one at https://www.goodfreephotos.com/testdoc.php

The testdoc page does not bring up a javascript error and the lazy load works fine, but on my actual page when I inspect on chrome, I get:

jQuery.Deferred exception: $(...).lazy is not a function TypeError: $(...).lazy is not a function
    at HTMLDocument.<anonymous> (https://www.goodfreephotos.com/:215:20)
    at l (https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js:2:29375)
    at c (https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js:2:29677) undefined
w.Deferred.exceptionHook @ jquery.min.js:2
jquery.min.js:2 Uncaught TypeError: $(...).lazy is not a function
    at HTMLDocument.<anonymous> ((index):215)
    at l (jquery.min.js:2)
    at c (jquery.min.js:2)

Does anyone know why, on my main page, it is ignoring my include from cloudflare and trying to find the lazy function in my google include, but on my test page, it works just fine.

It seems to work for me.

I just fixed it, the script I was using had an internal jquery load, I was trying to load the google one also and it caused a conflict.

1 Like

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