Ben Godfrey

Hijax

Got back from Mobile Monday drunk, snoozed for an hour and now I’m learning new hacking tricks! I surely do have the strangest working hours. I have an excuse, Louise started a new job working nights this week, she finishes at four and will be back in an hour. I wanted to stay up and wait for her.

Anyway, Hijax is the combination of two very cool ideas: 1. Ajax, 2. Progressive enhancement. Progressive enhancement, advocated by Jeremy Keith, in his book DOM Scripting (which I do not own and have not read), suggests that whizzy JavaScript functionality should be automatically added to a simple HTML page after the fact. So instead of building an app with a bunch of links that call JS functions, I’d create a vanilla web app with links to new pages. Then I would write JS code that goes and finds those vanilla links and hijacks them, replacing them in the DOM with links to teh whizzy.

This idea doesn’t just relate to Ajax of course, but it provides a foundation for building higher-quality Ajax apps. As Mr Keith so eloquently puts it: “progressive enhancement automatically guarantees graceful degradation.” Because the old links are still there for non-JS users (old browsers, browsers with no JS, search engines, etc) my app still works perfectly well, if less whizzily.

This is the single coolest JS trick I’ve ever come across, way cooler than all that Ajax rubbish :-). Deployment of JS whizzitronics follows the same model as the deployment of CSS beauty. The underlying content is preserved, so you can have your cake and eat it too. I highly recommend reading Jeremy’s blog and the sample chapter as he explains this stuff much better than me in my tired, post-booze state.

Bookmark and Share

Comments

charlie's avatar

charlie

whilst not being fully versed in the tech I get the idea; too right! JS really slows down mobile connections and on the busiest pages slows the phone to a crawl while the script runs. graceful degregation sounds like real progress.
Cancel
mat's avatar

mat

Thank fuck! Someone making sense about JS/ajax. That is exactly how it should be done..

My take on AJAX has always been "oh, that's very clever. how does it degrade? It doesn't? Not interested." I did some good things in the Hijax vein with Jim@Soup. Course, we didn't call it anything fancy, it was just sensible development.. :)
Cancel

Ben Godfrey http://aftnn.org

I know! It's like, "Yay, I can do that and not hate myself!"

It's great timing too, I'm redeveloping this site and want to do some Ajax whizziness for the gallery. I can now deploy these techniques on that project.

I'm seriously considering buying the book now. Just need to find a bookshop so I can leaf through it a bit first.
Cancel

Add a new comment

Your avatar

Add a new comment

Cancel   Forgot password?
Cancel

Attention! Log in (if you've commented before) or use your OpenID.

You can use Markdown here.

Preview