Filed under: jquery,opinion,web development — jaydublu @ 4:03 pm

Every now and then I come across a new product or technique that causes a lightbulb to come on – suddenly I know I will never code the same way again.

Landmark events over the years might include the realisation that PHP is a proper programming language (although I did keep Perl up my sleeves for the odd task), how to use Subversion to version control a website (must write that one up sometime), reading Zeldman’s “designing with web standards”

Not quite in the same league perhaps, but I’ve finally got around to having a good play with jQuery, and doesn’t that open up whole new fields of possibility?

Having ‘bought into’ Standards there has always been an internal conflict with any superfluous markup that has to go on a page for eye candy or other frippery, such as the dreaded rounded corners problem. Suddenly, there is a simple way to tinker with the DOM to make such effects possible, without having to put anything more in the base code than a few calls to JavaScript includes. But it sounds too good to be true. It can’t be legal can it?

I suppose the answer to that is that there isn’t one answer – it all depends how you wield the tool. If you disable JavaScript and the page still ‘works’ – then all jQuery is doing is adding some glitz and if it’s keeping the markup etc. cleaner and more semantic then that has to be a good thing.

But what is the definition of ‘works’? It depends what the page is meant to do. It could be an informative page so ‘works’ is can you access the content in the correct context and get appropriate meaning from it. Or it might be a bit of functionality – a form or a blog or whatever.

With the power comes responsibility, and the temptation to run riot and get all inappropriate. I’ve seen some pretty dubious examples of the use of jQuery – putting ‘back to top’ links on a page, or altering anchors if they link to external resources – that starts risking Accessibility and potentially usability. Use of AJAX without a non-js method of doing the same thing – form validation and submission for instance. Face it you could use it to construct a whole site on the fly if you wanted. But that would be a Bad Thing in my book unless there was exceptional reasoning behind it and some sort of mitigation for non JavaScript users.

I’m sure I will be making a lot of use of jQuery in the future, but I will be keeping a close check on myself to make sure it’s appropriate. For reference, here’s a simplistic view of how I tend to approach a new build currently:

  • Analyse what the page is about and prioritise requested / identified features in a sort of MoSCoW list
  • Design html structure to represent it, check it makes sense in text browser
  • Analyse ‘look and feel’ requirements and design css / JavaScript to implement them
  • If necessary adjust html to make the presentation layer easier / possible, but as little as possible (argue negotiate with client / designers as appropriate)
  • Never forget a print stylesheet, and probably nowadays it would be good to consider mobile devices
  • Do everything server-side to deliver the page and handle any actions the page produces
  • Complete content population & coding
  • Test degradation from latest browsers with everything turned on through old browsers, text browsers, phones, anything I can get my hands on until I get bored- ensuring ‘must have’ features work in all, ‘should have’ and ‘could have’ work in as many as is feasible.

Does ‘one web’ mean ‘one website’?

Filed under: mobile,opinion,web development — jaydublu @ 5:05 pm

Ongoing discussions with a colleague about the most appropriate way to deliver websites that are mobile friendly, led him to send me a link to a blog posting in the Opera Community: ‘Open Standards, One Web, and Opera‘. He reckons this demonstrates his view that you should build a standards compliant site, and leave it to standards compliant browsers to adapt. For the record my view is that whilst this approach may work most of the time, better experience can be given to the visitor if you tailor the code being delivered by the server to suit device capabilities.

Summarising the main argument of the piece:

We believe very strongly in 2 main principles:

  1. One Web — first coined by the W3C, the one Web principle is what it implies — there should be one single Web that can be accessed by any Web—enabled device, not different content for different devices — this is unsustainable, and a maintenance nightmare — having to maintain several versions of the same content can be really frustrating. The “one Web” is made possible by…
  2. Open standards. Technologies such as CSS and HTML are open — they are free for anyone to use and get involved in the evolution of, and because they are also standards, pages created using them should be viewable on any device by anybody, as long as user agent vendors follow the standards. Most vendors, including ourselves, are making a pretty good job of this these days, mostly (hint — there is still a bloated giant out there that has trouble with standards, despite controlling over 70% of the browser market. We won’t name any names…) Proprietary standards, that is, standards that are not free for anyone to use and lock you in to having to use a single/few company’s products, are bad for the one Web, and are often inaccessible (that is, not usable by users with disabilities) and expensive to develop with.

I can’t and won’t argue against either point – I believe in them too, but that doesn’t mean I necessarily agree with the implication that ‘one web’ implies ‘one website’ – i.e. one set of code that gets delivered to all devices.

That’s getting a bit close to ‘lowest common denominator’ where you don’t use particular techniques or features if not supported by all devices you’re building for, or another risk is that you’re abandoning a chunk of your audience for the sin of not using a standards compliant browser (that could be 90%+ of your potential audience!)

Where in those two principles does it say you can’t adapt code a bit to suit device capabilities – and before I get screamed at for suggesting multiple sites / thousands of separate templates / layouts etc. note the phrase ‘a bit’ – and use some of the power going spare in our modern day servers? A pragmatic approach rather than dogmatic.

‘One Web’ is about content – reading what the W3C say about One Web in their Mobile Web Best Practices:

“One Web means making, as far as is reasonable, the same information and services available to users irrespective of the device they are using. However, it does not mean that exactly the same information is available in exactly the same representation across all devices. The context of mobile use, device capability variations, bandwidth issues and mobile network capabilities all affect the representation.”

i.e. The content should be the same, but the way it’s being presented could be adapted to suit the device.

Not all devices / browsers are equal – some have very special needs, particularly mobile ones. Even if they can render full standards compliant web pages, there are problems of bandwidth and memory. Mobile devices will perform better with nice light pages, whereas Desktop users are perfectly happy with big bloated ones.

Screen size and navigation – yes I love the iPhone’s zooming, but at the end of the day when you start to read a site or try and use the navigation, the screen is only 320×480 pixels, and a fat finger is less precise that a mouse. So the likelihood is that a navigation system that works well at 1024×768 with a mouse, might be a bit fiddly on an iPhone, let alone a mobile using a simulated mouse or keys, on the other hand something simple enough for a mobile might be really tame on a Desktop.

But which standard? xhtml is getting wider support within higher spec phones now, but it’s still widely regarded that XHTML-MP is supported by the overwhelming majority of mobile browsers. And what about old phones that prefer WML? Just because you’re sending different markup to different devices doesn’t mean that the markup used won’t be standards compliant.

In summary – ‘one web‘ – yes. ‘Use standards‘ – yes. But adapt the output a bit to better match device capabilities. If my understanding is right that’s also what the W3C is saying.