Home › Forums › JavaScript › Prevent Image load till visible?
- This topic is empty.
-
AuthorPosts
-
November 26, 2010 at 7:31 pm #30816noahgelmanParticipant
I’m using the jQueryUI Tabs to show a small gallery of images. I’m a bit worried about load time. Is there a way to prevent the non-visible images from loading till the user selects the tab to make them visible?
November 28, 2010 at 4:55 pm #71934noahgelmanParticipanthmm… no ideas on this one?
November 28, 2010 at 11:53 pm #71904jamygoldenMemberTry setting their display to none with css and use jQuery to make them display: block when the tab is clicked.
November 29, 2010 at 2:35 am #71914noahgelmanParticipantIf they’re displayed:none, would the browser still load them on page load?
November 29, 2010 at 5:40 am #71884jamygoldenMemberI remember images not being loaded until I set the display to ‘block’ – Which was a problem at the time lol.
November 29, 2010 at 12:08 pm #71806TheDocMemberThere is a really cool way of doing this that I’ve seen lately, but I don’t know what it’s called!
Ah ha! – Lazyload http://www.appelsiini.net/projects/lazyload
November 29, 2010 at 1:36 pm #71803noahgelmanParticipantI came across lazyload, but the disclaimer at the top worries me.
“Lazy Load is currently not usable. It does not work with the latest browsers as expected. I have currently no time updating the code myself. Patches are always welcome. If you find a solution just fork and send a pull request. Thanks!”
And that was written in September of 2007. That sounds like something to be concerned about. Plus it says it doesn’t work in safari and looking at the comments, there are some Firefox 3.6 issues
November 29, 2010 at 2:17 pm #71793TheDocMemberAs far as I can see, it works on modern browsers (as I visit quite a few sites that use it). The disclaimer at the top didn’t make any sense to me.
November 29, 2010 at 4:12 pm #71770noahgelmanParticipantI have another question maybe you can clarify the meaning of
“Lazy loader is a jQuery plugin written in JavaScript. It delays loading of images in (long) web pages. Images outside of viewport (visible part of web page) wont be loaded before user scrolls to them. This is opposite of image preloading.”
Does this only work with images further down the page, or also with images inside hidden divs?
November 29, 2010 at 4:40 pm #71766TheDocMemberI’m actually unsure, to be honest with you. You’d have to test that out.
November 29, 2010 at 4:46 pm #71767noahgelmanParticipantK, well I’m going to wait to mark this as Solved to see if anyone else has any ideas for any other options.
November 30, 2010 at 3:21 am #71703jamygoldenMemberHave you given the display: none approach a try?
November 30, 2010 at 10:49 pm #71659noahgelmanParticipantI havent on the images themselves, but the div they’re in. Does setting the image to display none increase loading speed?
December 1, 2010 at 12:03 am #71661jamygoldenMemberDo they have to be <img> elements? I did a test and if an element is set to display none, the background image isn’t loaded.
December 1, 2010 at 1:15 am #71665noahgelmanParticipantYeah, they’re elements, background images aren’t an option
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.