[proposed filter] - combine images, replace all img tags with absolute divs, sized and offset

5 views
Skip to first unread message

Luke Kenneth Casson Leighton

unread,
Aug 29, 2017, 8:14:55 PM8/29/17
to mod-pagesp...@googlegroups.com
hiya guys,

ok so this is a trick that i learned from GWT, and i thought it might
be something you could also investigate. it's quite.... well... it
would be... interesting if it succeeded. GWT specifically deployed
this trick because it worked, and they could do it easily because they
had access to the more powerful programming language (java) and the
abstraction that goes with it. the end-result was javascript (GWT is
a java-to-javascript compiler after all) but that's beside the point.
process is as follows:

* take all images
* stuff them into one big image as a collage
* remember where each image is!
* take all img tags
* remove them and replace them with a div
* set the div to be the *exact* same size as the original img tag
* for each div create an associated CSS "style" with the following properties:
- offset x corresponding to the coordinate in the "collage"
- offset y likewise
- background-url: the big image

now, i can't exactly recall if that's exactly how it was done: they
*might* instead have done it by creating a wrapper div with "posiion:
absolute" then making all <img> tags be positioned *inside* that
wrapper div, such that the coordinates (which would always be negative
or zero) *HAPPENED* to *EXACTLY* coincide with the section of the
collage which contained the *original* image before the page was
modified.

it's quite a neat trick and the GWT team used it basically to download
only one image, once and only once.

now, whether that would be a good thing or not - whether some browsers
carrying out parallel downloads actually would retrieve individual
images faster than a "collage" of all images - remains to be
determined.

anyway, thought you might want to put this one in a queue somewhere if
it's not already been considered.

l.
Reply all
Reply to author
Forward
0 new messages