Monday, 4 October 2010

Web blasphemy

A while ago Andrew Donaldson wrote an interesting article on how "gut reactions" to things in web development can actually close our eyes to new ideas (in which he brutally mangles my approach to CSS :-)). I think the key point in our discussions is summed up nicely: "When discussing the presentation with my friends I remember saying 'I don’t know why I don’t like it, but I just don’t'".

This week I was watching Julien Lecomte's awesome talk on high performance ajax which touches on this subject which a worthy example. He is talking about breaking a small rule for a big payoff and mentioned replacing span class="bold" with the deprecated b element to make a big file size saving (in his example where displaying perhaps 1000 results).

I found myself immediately thinking "well, surely you'd page the results and so the saving would be dramatically lessened". Which, of course, is not relevant to the point being made, but was a knee jerk reaction on my part to the blasphemy of using deprecated elements! It made me think of how many other possible savings or great ideas I'd missed because my standards advocacy had placed me firmly back inside the box.

6 comments:

  1. I watched that High Performance Ajax vid and it's like he went out for drinks with you the night before. It's all the stuff you've been saying for months wrapped up in one vid.

    That said... Coding with performance in mind at the start, what the hell?

    BUT. In javascript it does make sense. I find it much easier in javascript to accumulate slow code rather than keep things trim. Maybe if I approached with performance up front I'd find the performance easier to keep a handle on later on in the project.

    In Javascript, writing with performance in mind doesn't mean writing impenetrable code, it just means 'know what approaches are fast and which are slow'. It's almost more coding style than performance.

    For the other languages I code in I'm still a firm believer in Make it work / Make it pretty / Make it fast :)

    ReplyDelete
  2. I think a lot of this worry about optimisation depends on project scale. I just flung together a 1 page site for myself and sprited up my four icons, which, really, just makes me look a fool :). However, saving 4 http requests on the Yahoo homepage is a completely thing.

    So, in some ways a lot of these videos are just geek porn, because the savings won't scale to be noticable on the projects most folk are working on. Don't get me wrong though, I think it's important to know how to code to this level, but it's equally important to understand its application.

    ReplyDelete
  3. Could he not have replaced <span class="bold"> with a <strong> or a CSS-overridden <em> if space was an issue?

    It's your approach to semantic code and not using deprecated things that got me where I am today. You should have seen my markup pre-Conscia. Thankfully there's none on the web any more.

    ReplyDelete
  4. I shouldn’t reply to old posts but I can’t help myself.

    <b> is not deprecated. It never has been. In some circumstances it’s a good idea to use <b> over <strong> or others.

    <span class="xxx"> carries the following semantic information: “This is some text. It is part of the same semantic block as the surrounding text. This text may carry some additional semantic information that is not represented by this markup, or perhaps it has a behaviour implemented in script. If you’re lucky you might be able to guess that semantic information from styling applied by the stylesheet.”

    <b> carries the following semantic information: “This is some text. It is part of the same semantic block as the surrounding text. If this text were set in type, it would stylistically offset from the surrounding text for unspecified reasons – specifically, it would be bold. I’m letting you know because perhaps you can infer some additional semantic information from that knowledge.” (It also carries some additional formatting information that says: “make this bold please”.)

    <strong> carries the following semantic information: “This is some text. It is part of the same semantic block as the surrounding text, but it’s more important. You should pay attention to this text in particular.”

    In other words, <b> is usually better than <span> if you want bold text, and it’s better than <strong> in some cases — for example, if the text is from user input that included formatting information but not semantic information.

    ReplyDelete
  5. Please feel free to back comment as much as you like! In a site with a total of 5 comments I don't think it can be a bad thing.

    B is indeed not deprecated, I was merely talking crap. However, it is a stylistic element and a parochial one at that, thus a candidate for deletion IMHO. It's been a long road getting a styling layer which is to a fair degree separate from the markup. So I would disagree that b is better than span on those grounds.

    I realise that in my hastily scribed post I did not make it clear that the content to be made bold was purely for formatting, thus elements with strong semantic meaning would add disinformation to the page.

    ReplyDelete