Generating a spacer gif on the fly

David Brown david at no.westcontrol.spam.com
Wed Oct 9 10:09:58 EDT 2002


"Max M" <maxm at mxm.dk> wrote in message
news:1iWo9.86937$Qk5.3920943 at news010.worldonline.dk...
> David Brown wrote:
> > "Max M" <maxm at mxm.dk> wrote in message
>
> > There are a number of reasons - you'll find more information by doing a
> > quick web search, or posting to web design newsgroups (since it is a web
> > issue rather than a python one).
>
>
> I think I know the reasons, but I just wanted to hear your argument, as
> the other one was a bit brief ;-)
>

It looks like you've thought things through - as I said, while there are
many reasons to avoid spacer gifs, they may still be a sensible choice for
the job.  After all, spacer gifs (along with absurdly mixed-up nested
tables) have been used for layouts by many others (including myself on
occasion).

> > But just to give a few reasons, it is much
> > slower and less efficient to use an image (which must be seperately
> > downloaded, even if it is small) than CSS positioning,
>
>
> It gets cached. I have never seen this to be an actual problem. It's 43
> bytes.
>

It's not the 43 bytes that takes time/bandwidth, it's the extra tcp
connection, http request, processing, handshaking, etc. that takes time.
Yes, it can be cached, but be careful that caching is in fact allowed when
you are generating the page on the fly - dynamic content pages often
disallow caching so that they are always up-to-date (note - I haven't
actually used Python for generating web pages, I've used PHP for that, so I
don't know what sort of default headers are sent out.  I just know that
*you* need to know :-).

> > it can make a real
> > mess if the user has turned off image download,
>
>
> Hmmm... then my pages would look a mess anyway...

It all depends on your target audience and the sort of content your serving.

>
> > it makes a mess of the page
> > if the user saves it as html for later reference,
>
>
> That depends a lot on how the browser saves the page. And not really
> something I will take into account. If users decides to use dynamic
> content outside it's enviroment, that's their problem ;-)

Again, that depends on the audience and the content.

>
> > it may be wrongly taken
> > for a "spy dot" (I don't know if that's the correct term, but it
describes
> > what I mean - an invisible gif, frequently sent in html email, used to
pass
> > information back to a server when the user reads the page),
>
> Spy dot's are not a problem on a webserver. Only in html mail, which I
> don't inted to use it for.
>

That's true (spying is easy when browsing - you only need the spy dot for
email).  But there may be programs out there designed to trap spy dots (I
don't know if such programs exist, but if not, then they should do!) in the
same manner as there are blockers for website adverts.  They would treat web
pages in the same way as email.  Of course, this could be a completly
imaginery problem, if no such blockers exist.

> > it causes havoc
> > if the user is doing something you don't expect (such as using their own
> > preferred fonts, or magnifying the page, or using a text-only browser,
or
> > using a reading program because their are blind or have poor vision).
>
>
> These points has some validity but you can design around them.
>
> The most important one is the disadvantaged user. For those I prefer to
> create a simpler view of the page anyway.
>
> > And if all that doesn't turn you off, and you want to continue despite
> > everything you might read elsewhere against spacer gifs (which are an
easy
> > solution, so despite their many disadvantages they may still make
sense),
> > then use a single transparent gif so you don't need to worry about
colour.
>
>
> A spacer works uniformly in any browser. I have never had a complaint
> when using them. Transparent spacers are the most common but not the
> only one needed.
>
> A single pixel multi colored gif can be used for several purposes in
> layouts, like creating vertical lines:
>
> <td align="center"><img src="<%= spacer('#844221')%>" width="2"
> height="100%"></td>
>

I have used scaled single-pixel gifs to create bar graphs - it's very
efficient for that sort of thing.

Do you really need a completly free choice of colours?  If you can specify a
few and make them static files, it will be a lot more efficient.

> I have Art Directors demanding all sorts of unreasonable things all the
> time ;-)
>
>
> regards Max M
>
>  ><evolve>
>    >    >
>





More information about the Python-list mailing list