Wedge

Public area => The Pub => Plugins => Topic started by: live627 on February 11th, 2012, 02:37 AM

Title: Lazy Load Inages
Post by: live627 on February 11th, 2012, 02:37 AM
I got this idea from http://www.appelsiini.net/projects/lazyload (actually, I saw jQuery website's avatars  do this). So I decided to make a plugin for Wedge that does just this.

What it does (or will do, as I didn't write it yet) is hook into the buffer, find all img tags with a regex, use data-src for the image link, put a blank grey image as its src, and wrap noscript tags around a copy of the original img tags to not leave noscript users in the cold. Then the jquery changes data-src to src when it is scrolled into view, vertically or horizontally.

And I also  attacked the script to remove unneeded cruft. Now, it is a nice 277 bytes once minified and gzipped. (2KB uncompressed)
Title: Re: Lazy Load Inages
Post by: Arantor on February 11th, 2012, 02:59 AM
:whistle: http://wedge.org/pub/feats/7001/ideas-from-the-oddest-places/

In our case, the real bulk of images that this will affect are user supplied (pretty much all the base images are CSS driven), but I suppose it might make a difference.

Note that data-src is not wonderfully supported (IE, Imma looking atchu) but the idea is certainly worth experimenting with.

Also, please let me know if you have trouble with the buffer hook, because it's a buffer not a conventional hook and I have a slightly funny feeling it may not work properly.
Title: Re: Lazy Load Inages
Post by: live627 on February 11th, 2012, 04:25 AM
Quote from Arantor on February 11th, 2012, 02:59 AM
:whistle: http://wedge.org/pub/feats/7001/ideas-from-the-oddest-places/
Is there anything you have NOT discussed?? Oo
Quote
In our case, the real bulk of images that this will affect are user supplied (pretty much all the base images are CSS driven), but I suppose it might make a difference.
Ooh, the gallery is big on that.
Quote
Note that data-src is not wonderfully supported (IE, Imma looking atchu) but the idea is certainly worth experimenting with.
The original uses data-original, but the same principle. It works in IE8, so I'll probably turn it off for 7 and below.
Quote
Also, please let me know if you have trouble with the buffer hook, because it's a buffer not a conventional hook and I have a slightly funny feeling it may not work properly.
Oh yes, I'll let you know.
Title: Re: Lazy Load Inages
Post by: Nao on February 11th, 2012, 08:57 AM
How could data-src not work well on IE..? I mean, any single inline event in Wedge is driven by a data-eve... :^^;:
Title: Re: Lazy Load Inages
Post by: Arantor on February 11th, 2012, 02:36 PM
Quote
Is there anything you have NOT discussed?? Oo
Oh, sure, there are things not discussed, but it's interesting to note when things have been mentioned before, too.
Quote
How could data-src not work well on IE..?
Meh, I was thinking of something else (data:// URL for encoding an image inline) which isn't so well supported, ignore me.
Quote
Ooh, the gallery is big on that.
It is, but I'm not clear on exactly how much benefit you'd get when you're serving typically 5-6 images lazily versus everything else via CSS.
Title: Re: Lazy Load Inages
Post by: Nao on February 11th, 2012, 04:55 PM
data:uri is only not supported in IE6 and IE7, and it never broke anything since Wedge just skips conversion for them :)

Oh gosh, the latest .Net issue (which arrived today at the same time as my Web Designer Mag issue, could you guys please avoid doing that? I'd rather have them two weeks apart thank you very much :P), they're discussing LESS in their "CSS hacks" pages, and again in their developer pages, to give examples etc...
Did ANYONE tell them that not everyone cares about installing Ruby (SASS) or Node.js (LESS) on their server?! :P
Perhaps I should release WeCSS as an open-source library for everyone to use... Then maybe .Net would be willing to discuss Wedge at all when we go gold :P
Title: Re: Lazy Load Inages
Post by: Arantor on February 11th, 2012, 05:05 PM
Installing Node.js on a server is a non trivial task, far more so than Ruby is - because Node.js isn't a drop-in for Apache or similar (unless they're doing something funkyweird in it) but that it conceptually IS the webserver as well as the application.
Title: Re: Lazy Load Inages
Post by: Norodo on February 11th, 2012, 06:19 PM
Quote from Nao on February 11th, 2012, 04:55 PM
Did ANYONE tell them that not everyone cares about installing Ruby (SASS) or Node.js (LESS) on their server?! :P
Very true!
Quote from Nao on February 11th, 2012, 04:55 PM
Perhaps I should release WeCSS as an open-source library for everyone to use... Then maybe .Net would be willing to discuss Wedge at all when we go gold :P
This would be an act of good faith, and I think it is a good idea. Make sure however that this does not burden your time considerably.
Title: Re: Lazy Load Inages
Post by: Nao on February 13th, 2012, 06:19 PM
Quote from Norodo on February 11th, 2012, 06:19 PM
This would be an act of good faith, and I think it is a good idea. Make sure however that this does not burden your time considerably.
Time is the main problem indeed...

If someone else was willing to manage the project, then I could consider doing it.
Title: Re: Lazy Load Inages
Post by: Arantor on June 4th, 2012, 07:36 PM
Randomly today I came across https://github.com/pedromenezes/jQuery-lazyload

Might see about making that a plugin sometime.
Title: Re: Lazy Load Inages
Post by: Nao on June 4th, 2012, 10:27 PM
I'm pretty much anti-laziness myself when it comes to images. It has its uses but mostly in an infinitely scrolling page.
Title: Re: Lazy Load Inages
Post by: Arantor on June 4th, 2012, 10:46 PM
That's true, I guess.