They Say You Die Twice
I mean, they say you die twice. One time when you stop breathing and a second time, a bit later on, when somebody executes your code for the last time.

I mean, they say you die twice. One time when you stop breathing and a second time, a bit later on, when somebody executes your code for the last time.
With the prevalence of jQuery tutorials and JavaScript advice in general, it's common to see JavaScript events bound to the click event.
Without jQuery this is done with:
document.querySelector(selector).addEventListener(
"click",
function (e) {
// ...code here...
},
false
);
(for purposes of this example, we'll assume that there's only one element in the selection)
With jQuery this is done with
$(selector).click(function (e) {
// ...code here...
});
...or...
$(selector).on("click", function (e) {
// ...code here...
});
Seeing this code, you could be forgiven for thinking that ...code here... is where you start writing your functionality when adding a click handler to a hyperlink.
Simple AJAX examples often appear as:
$("a").click(function (e) {
$.get(this.href).then(doStuffWithResults);
e.preventDefault();
});
That code is terrible. Don't ever use it.
The problem with that code is it completely ignores what is doing the clicking.
You see, when a link is clicked, the user has the option of telling the browser how they want to navigate with that link. The majority of the time the user will simply left click, because the user wants to navigate directly to that link.
But occasionally users do things differently. Users might middle-click or Ctrl + click a link to open it in a new tab. They might Shift + click the link to open it in a new window.
In those cases, the click handler will do the wrong thing.
For the first time since 2008, my home computer is not connected to my Das Keyboard Model S Ultimate with it's exquisite Cherry MX Blue clicky switches. It's been a good run, and seven years is nothing to shake a USB cable at. My keyboard served me exceptionally well for the last seven years, and I can honestly say it's the best keyboard I've ever owned.
After more than five years of knuckle-hair and dust, I removed all the keycaps and gave it a good cleaning. It was around that time that the Enter key on the numpad began to stick a bit. Nothing a little silicone spray couldn't fix, but I'd just never gotten around to fixing it because I hardly ever used that Enter key anyway.
I read a lot of blogs. Blogs that have rich and meaningful content. They tell stories and provide nuanced perspective into many aspects of life. They are often written by people who are not writers, but still have something important to share.
Unfortunately, they are often designed by the same people.
Some days, everything is Comic Sans. This link is a bookmarklet that will help with that.
Steve Faulkner gave an exceptional interview with Mike Smith about the Nu Markup Checker.
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
The reason it takes about a generation for these things to happen is that we never change the minds of the people who are most vocal against it. We just have to wait for them to die.
A bit of background on this one before I dive into a rant:
Just over three years ago, I wrote an answer on Stack Overflow regarding jQuery.fn.data() vs jQuery.fn.attr(). My answer, which really focuses on the utility of the .data() function, has essentially become the canonical answer for various niche questions and minor bugs relating to .data() and .attr(). I'm quite surprised and delighted by the popularity, as it's my highest up-voted answer.
What I just found out this evening disappoints me.

I felt like redesigning my wobsite, so I did. Check it out and let me know what you think in the comments.