At 11:09 AM 8/11/2006, Designer wrote:
Richard Czeiger wrote:
Hi all :o)
Just thought I'd throw a bit of code out there and see if anyone
thinks it's useful..
Unobtrusive Semantic Branding
http://www.grafx.com.au/dik/branding.html
Yes, it's interesting - but is there an advantage over pure
CSS? see [1]. It seems simple, but I knocked it up very quickly,
so someone may find a problem . . .
[1] http://www.marscovista.fsnet.co.uk/template/branding_CSS.html
Bob, you're presenting the markup that Richard's script produces. By
the time his script has finished running, his and your solutions are
both HTML & CSS. He's just using javascript to automate the
distribution of his solution throughout the markup.
Personally I think javascript is an odd choice for this. The
javascript solution won't execute until the page is loaded, so for
heavy pages there will be a delayed rendering. And of course the
branding won't render at all in browsers not executing javascript.
It's a little like distributing a book with a black & white cover,
plus a loose color cover. Cool! You can glue on your own color
cover! ...if you've got glue... But why not simply distribute the
book bound in the color cover in the first place?
Javascript is great for immediate user interaction, but for page
modification like this it seems slow, redundant, and inefficient. If
we're generating our pages server-side to begin with, why download an
incomplete markup to the client and then complete the markup with
javascript? It makes sense when javascript executes differently
based on user actions and on conditions found only after download,
but I don't see that here.
What does make sense -- and this is the intelligence at the core of
Richard's script -- is the separation of the brand name from the
brand styling. Because his method of branding (applying different
colors to substrings within the whole) requires specific markup, he's
inserting his classed spans into vanilla markup instead of
hard-coding the whole thing in HTML. This is smart. It's the
decision to perform this morph after download that I question.
In PHP, for example, it would be easy to assign a variable the
requisite markup, then invoke it in the script whenever necessary:
$sOurCompanyName = '<span class="brand"><span
class="b1">company</span><span class="b2">Name</span> ...';
...
echo "<p>Our brand is $sOurCompanyName and we think it rocks.</p>";
The specially marked-up company name is independent, easily
modifiable, defined only once in the application. It can be stored
as plain, unquoted HTML in its own text file so it's completely
separated from the PHP logic layer.
Additional food for thought: With buffering it's possible for PHP to
completely produce a page and only then release it for download to
the browser, rather than downloading it incrementally during
generation. This means that after page-generation has completed, one
can run additional processes on the complete, buffered markup before
download. Markup-tweaking functions can be slapped onto an existing
script without having to be merged with the flow of page-generation
-- one of the ways we've used javascript in the past.
Finally, although Richard's script is unobtrusive in the sense that
it doesn't fundamentally break the page if javascript isn't running,
I did find it obtrusive from a developer's persepective. It's a big
whack of bandwidth to effect a very small change in markup, and brand
coloration -- the only goal of the script -- does in fact break in
the absence of javascript support in the browser.
Downloading the customized markup from the server seems like a much
more elegant approach.
Regards,
Paul
******************************************************
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************