News for hackers. Stuff that matters.
Re:JQuery Script to Automatically Preload images by qeorge on Thursday January 20, 2011 @03:13PM (#2125094)
I've used this on at least 10 production sites, for years. It works great.

The Filament Group blog is filled with gems like this, highly recommended reading. FWIW, Filament Group contribute heavily to jqUI, and developed Themeroller.

Re:JQuery Script to Automatically Preload images by JoelSutherland on Thursday January 20, 2011 @01:49PM (#2124760)
I wish it were possible to delay the loading of images using JS. That would allow them to be swapped for images that were the appropriate resolution for the device looking at them.

This is this big issue with responsive web design. There is a solution, but it requires both modifying HTML and additional HTTP requests:

http://filamentgroup.com/examples/responsive-images/

Re:JQuery Script to Automatically Preload images by Groxx on Thursday January 20, 2011 @02:09PM (#2124857)
Why wouldn't it be possible? Just make placeholder div tags with fixed and accurate size (unless you don't mind re-flowing as they load - I dislike it), then JS the device type and create img tags on the fly.
Re:JQuery Script to Automatically Preload images by JoelSutherland on Thursday January 20, 2011 @03:50PM (#2125208)
That is effectively the same (but not quite as nice) as the solution I linked to.

The problem is that I can't ask Joe Client to create placeholder divs. I want to handle it magically for him.

Re:JQuery Script to Automatically Preload images by Groxx on Thursday January 20, 2011 @07:36PM (#2125943)
But you can ask Joe Client to make everything as they like, and then post-process it when it's saved, shrinking images and replacing them with placeholders automatically.

edit: looked at page code.

Isn't that nearly the same as placeholders though? You're asking them to suffix their images, and add a non-standard attribute to every one they want to load dynamically. That burden, and the image resizing, is all done by Joe Client via that framework, under identical assumptions. That's not magical, and it's functionally identical to what I proposed, but it causes extra requests.

Re:JQuery Script to Automatically Preload images by JoelSutherland on Tuesday January 25, 2011 @11:36AM (#2139651)
It is nearly the same as a placeholder. The advantage is that even without JS, it still functions and has meaning. This is a big advantage.

Just as your placeholder could happen in post processing, so could the suffix and attribute be added.

Having looked into this more there seem to be only three decent approaches. 1) Send the small image first potentially causing extra HTTP requests. 2) Require JS to make a placeholder swap. 3) Cap the image dimensions server side based on a User Agent/Resolution table.

Option 3 is terrible to implement but avoids the downsides the others have.

Re:JQuery Script to Automatically Preload images by SkyMarshal on Thursday January 20, 2011 @02:43PM (#2124978)
Thanks for posting this, I was just thinking about this problem on a website I'm building. Very useful, though I also wish JS could do handle it.
Re:JQuery Script to Automatically Preload images by acdha on Thursday January 20, 2011 @02:56PM (#2125045)
Am I missing something? You just load a placeholder image and then after page load (or hitting a certain document scroll position or …) you alter the img src to point at the desired image. The main trick is avoiding making this jerky, which might really be more of a case of a single placeholder and then generating images on the fly as appropriate for the form-factor.
Re:JQuery Script to Automatically Preload images by nixme on Thursday January 20, 2011 @06:22PM (#2125755)
For that particular use case, check out http://tinysrc.net/
Re:JQuery Script to Automatically Preload images by jetz on Thursday January 20, 2011 @02:12PM (#2124868)
it's possible but i don't know how to do it. look at youtube result pages. it only loads the images in the visible browser screen and as you scroll down it loads the remaining.
Re:JQuery Script to Automatically Preload images by bherms on Thursday January 20, 2011 @02:59PM (#2125050)
You're thinking of lazy load. He's talking about something different. If you were wondering how to do that, though, here is a link http://www.appelsiini.net/projects/lazyload
Re:JQuery Script to Automatically Preload images by JoelSutherland on Thursday January 20, 2011 @03:52PM (#2125211)
This would be perfect, but if you read the notice on the top of the page, it no longer works with current browsers.
Re:JQuery Script to Automatically Preload images by bherms on Friday January 21, 2011 @02:53PM (#2128620)
Oops, had it in my list of useful links note in evernote. Haven't looked lately. There are others out there that work.
Re:JQuery Script to Automatically Preload images by teye on Thursday January 20, 2011 @03:17PM (#2125106)
Wouldn't it be better to put this in load instead of ready so it won't slow down the loading of visible images or other resources?

(Ready = DOM is ready, load = page elements are loaded)

Re:JQuery Script to Automatically Preload images by mrkurt on Thursday January 20, 2011 @02:53PM (#2125023)
The article's not loading for me, but I can't figure out why you'd bother with jQuery to preload images instead of pure Javascript and the image object...

--edit--

Oh, it just loaded. It looks like it's meant to preload CSS images, which makes more sense.

Re:JQuery Script to Automatically Preload images by bherms on Thursday January 20, 2011 @03:00PM (#2125053)
Yep, exactly. It crawls the CSS for images and preloads them with jQuery.
Re:JQuery Script to Automatically Preload images by mhitza on Thursday January 20, 2011 @04:03PM (#2125242)
But it still can be made with image objects.
Re:JQuery Script to Automatically Preload images by NHQ on Thursday January 20, 2011 @06:14PM (#2125723)
Any know of a similar script for preloading inline images?
Re:JQuery Script to Automatically Preload images by juddlyon on Thursday January 20, 2011 @06:36PM (#2125792)