Classic Browser Politics: Are DOM Elements Global Variables?

This is hilarious:

A co-worker noticed something strange happening in his Chrome browser: Every element in an HTML page that has an id attribute gets attached as a member of the global window object!
I checked and it happens in my Safari as well. A bit of googling led us to the answer at StackOverflow:

What is supposed to happen is that ‘named elements’ are added as apparent properties of the document object. This is a really bad idea, as it allows element names to clash with real properties of document.

IE made the situation worse by also adding named elements as properties of the window object. This is doubly bad in that now you have to avoid naming your elements after any member of either the document or the window object you (or any other library code in your project) might want to use.

Opera copied IE, then WebKit joined in, and now both the previously-unstandardised practice of putting named elements on document properties, and the previously-IE-only practice of putting them on window are being standardised by HTML5, whose approach is to document and standardise every terrible practice inflicted on us by browser authors, making them part of the web forever. So Firefox 4 will also support this.

This is such a funny turn of events. And a great metaphor for how these inner decisions are made in browser politics.

jQuery stacheComb: Loading a Handlebars.js Template Into the Page

Handlebars.js is great.

It’s a superset of the brilliant mustache template engine, written especially for Javascript and with client-side in mind, and it provides a very elegant and organized way for using templates on a rich client-side application. If you’re looking for a template engine, I highly recommend looking into it.

I got to know it working on a previous application that I built around the uberkool Sammy.js framework. Among all of its features, Sammy lets you announce you’re going to use a template for the main element and it would handle the loading and inserting of template content into the page.

Now, working on another app that’s not using Sammy, I needed to get this specific functionality, with a touch of improved performance;
I needed a plugin that, like Sammy, would make an AJAX request for the template file if it doesn’t have it loaded yet, but additionaly in the production environment, I could just add these templates to the main markup (i.e. in a build script) and the plugin would use them without another request.

This was fairly easy but I thought I’d share the result: The jQuery stacheComb plugin.

Log in, Continue

Log in sucks.

I hate logging in to stuff.

On my own devices, I always tick ‘Remember me’. I never log out. Why should I?

The reasons for logging in are all understandable.
It’s a solution for many problems.
But it’s a bad solution. Passwords are for safes in banks and usernames are just nothings.

When I try to do something and the machine stops me and shouts at me Error! You are not logged in! Your authentication failed! You do not have permissions for this task!, I feel stupid.
And machines are not supposed to make me feel stupid.

And what more, logging in absolutely breaks the user experience.
I get to a blog, I read a post, I read the comments, I like the post, I want to let the author know, I click “like”.
I get an ERROR MESSAGE. You need to be logged in to do that. Argh.
I log in, or sign up, or ‘forget my password’ (blerg) and then it takes me to the site’s homepage.
I… wait, homepage? I didn’t ask to be on the damn homepage.
I’ll try to find that post I was reading. I’ll try the “Back” button but it’d fail because of the POST call. I’ll give up. I’ll leave.
Are you happy, website?

Logging in and maintaining an account is an experience bug that should be fixed.
But in the meantime, would websites redirect me back to what I was doing?

Thanks.

I was reading this post by a guy named Stefan a few minutes ago.
I clicked ‘like’ and Posterous asked me to log in. I did, it took me more than a minute because I forgot the password for my old account, and then I got to a page with this message:

 

A perfectly normal turn of events!
But ‘normal’ is such an outstanding word in the web user experience world.

So, kudos to Posterous.
A good time to try my years-old “tech blog” idea.