Comments (5)
Hello @lawrencealexander10,
well, without seeing your code it's hard to tell what is wrong. But a common mistake is, that the images or elements arount have no default height set. For the borower this means, all images has a heihgt of 0px
. So at the page load all images will fit in the whole viewport and Lazy will of course load anything then.
So please check this at first. If this is not working I need to have more details. A jsfiddle reproducing the behavior, page access or something ...
from jquery.lazy.
I created a gist with my code that exhibits the unusual behavior: https://gist.github.com/lawrencealexander10/ccc53772446f2cf239e990f9b2342db3
I tried it another computer and it exhibited the same behavior.
When attempting a jsfiddle with the same code in the gist, it worked to the spec so I am unsure what the issue is.
Thanks
from jquery.lazy.
Hmm, as you said, the code workes fine and I see no problems there. Have you ever tried to log the lazy loading and see if Lazy really loads all images at start? You could do it like this:
$(function() {
$('.lazy').Lazy({
afterLoad: function(element) {
console.log(element.attr("src"));
}
});
});
from jquery.lazy.
Yes I have, and the console logs all elements immediately on page load. The only time this doesn't happen is when my viewport is on the bottom of the page on load. As I scroll up the images lazy load. I'm not sure why this occurs and the inverse doesn't
from jquery.lazy.
Finally I found your problem!
You didn't set a doctype
in your page. Just add <!DOCTYPE HTML>
to the first line and everything works fine! Without this jQuery can't detect the dimensions. And another hint. The <style>
tag should be placed in <head>
. Since CSS3/HTML5 it is possible to place those style tags everywhere too, but then it should be scoped
once.
from jquery.lazy.
Related Issues (20)
- Google PageSpeed
- In Computer works like a charm. not working on mobile devices HOT 1
- Images downloading twice in Chrome HOT 2
- How to use jQuery.Lazy() Plugin with an image containing a cache-busting hash HOT 8
- Issue when using jQuery.Lazy() Plugin with a function AJAX call HOT 5
- images aren't shown if they doesn't come to visibility by scroll HOT 2
- images with srcset load all at once HOT 2
- Slow image load handling HOT 1
- Custom Content Loaders broken with jQuery 3.x HOT 4
- Doesn't trigger when new elements are toggled in HOT 2
- JS Error When Using on Cloned Template HOT 3
- laravel-mix, cannot reuse lazy HOT 1
- Deprecated
- Defer the lazy loading HOT 1
- Don`t change src when exists HOT 4
- Intermittent image load with AJAX return
- Custom loader using Ajax fails (not even fired), while lazyloading images work. HOT 1
- Bugs with gsap scrolltrigger in Safari HOT 3
- Throttling by number of calls HOT 1
- Images loading twice HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery.lazy.