A JavaScript Curiosity Regarding addEventListener

I’m wondering why this code fails to stop a form submission

document.forms[0].addEventListener("submit",falsify, false);

function falsify() {
		return false;
}

and this code successfully kills it?

document.forms[1].onsubmit = falsify;

function falsify() {
		return false;
}

Try it out (Firefox/Safari/Chrome/Opera only- there’s no addEventListener support in Internet Explorer). The form action on both is an alert. The first executes every time. The second never does.

Anyone out there know enough about the inner workings on addEventListener to explain why those two similar code blocks behave so differently? I’ve poked around a lot of the usual suspects (mdc, ppk, w3c) and haven’t seen anything that speaks to the above behavior, so I’m opening it up to the Internet. Hopefully someone out there can satisfy my curiosity on this matter.

Code I Like: Batch Subversion Rename (Replace Underscore with Hyphen), Bash Script

That’s an unwieldy title, if I ever saw (wrote?) one. Still it describes the code in question exactly, so unwieldy will have to do for this post.

Anyway, for SEO purposes I’ve wanted to rename some of my files from underscore delineated (_) to hyphen delineated (-) for a couple of years now. I chose wrong when I originally launched this site, and since it’s huge (something like 400 static pages), I never wanted to actually go through with the renaming. And that was before I got the site into Subversion. With Subversion in place I couldn’t even use one of the many little file renaming apps out there. I’d have to do the work within SVN or else things would be bad. Very bad.

A disheartening problem.
Continue reading “Code I Like: Batch Subversion Rename (Replace Underscore with Hyphen), Bash Script”

Why Front End Performance Matters to Everyone, Not Just the High Traffic Giants

Yeah, Even to You. 🙂

I suspect it’s because the people that are most vocal about the subject are from places like Google and Yahoo!, but it seems to me that a lot of people think that front end performance really only matters for extremely high traffic sites. When talking about these kind of things with other engineers at conferences and the like I’ve heard something similar to the following a few times and it left me scratching my head:

“That stuff is for the Googles of the world. We don’t really need to focus on that with what we do.”

Continue reading “Why Front End Performance Matters to Everyone, Not Just the High Traffic Giants”

Two Easy Ways to Get Set Up With Amazon’s CloudFront

It made quite a splash recently so I’m sure some of you are curious about Amazon’s new Content Delivery Network (CDN) service, CloudFront. I know the Amazon Web Services suite of tools can be a little intimidating for non-developers, so this article outline how pretty much any reasonably technical person can get themselves up and running on CloudFront and can start reaping the benefits of geographical optimized content delivery.
Continue reading “Two Easy Ways to Get Set Up With Amazon’s CloudFront”

Code I Like – Link Prefetching

I was reading John Resig’s Browser Page Load Performance post earlier today and followed up from there on the concept of Link prefetching. Currently supported by Firefox 2+, Link prefetching is a browser based mechanism for fetching “future” content. Considering I wrote (and ultimately scrapped*) similar functionality for my gallery pages, I was obviously intrigued.
Continue reading “Code I Like – Link Prefetching”