This would be nice..
A signwriter-powered dropdown menu can heavily increase the number of http requests. This could be avoided with CSS sprites.
But how can we automate this?
This is what I imagine:
Before I generate the html for a menu, I call
signwriter_prepare_sprite($strings, $profile, $options);
Then for each call to
signwriter_theme_text($text, $profile);
signwriter will look if a text with this settings already exists in a CSS sprite, and if so, will automatically embed the CSS sprite with the appropriate background-position.
$strings will contain the labels of all the menu items, while
$options can contain some additional info, such as: line height, vertical vs horizontal tiles, etc.
------
We could even try to do without the preparation step, and assume that everything will be added to one big sprite, and in the end that sprite will be generated.
So:
- First time that signwriter_theme_text() is called, it will generate a unique file name (png or gif) and return html with a background-position with y=0. The text needs a height of 30px, so we remember that number.
- Next time, signwriter_theme_text() will return html with a background-position of y=30px.
- Next time, we have background-position with y=60px.
- etc.
- In the end of the request (or when the file is requested), signwriter can create the image from the collected information.
But what if we already have an existing sprite?
We don't want to waste time on generating it again!
Yes.. so now signwriter_theme_text() can first have a look if that string is already covered by an existing sprite, and then deliver that existing sprite, plus an additional one with the missing pieces.
At the same time it can prepare a new sprite that contains the existing terms plus those that were added in this request, for the next visitor who does not have the old sprite files in his browser cache.