Setting a cookie in Javascript shouldn’t be THAT difficult

With Javascript becoming increasingly popular, I’m still shocked at how bad the online documentation and examples are.  Let’s take the search phase “setting a cookie in javascript“, a fairly common problem which I always forget the correct syntax for.

The first four results are as follows:

Sorry to the original authors, but each one of them IS AWFUL!

Let’s take W3Schools as an example. It defines a variable called ARRCookies are could be for Pirate Cookies (via @Blowdart) or ARRay (via @AndrewVos) – both of which are great examples of creating Clean Code. To make matters even worse, this example has spread like a virus with Google returning 288,000 results and GitHub returning 398.

The best link which describes handling cookies, and generally any Javascript documentation, can be found on the Mozilla Developer Network (MDN).

While I’m not an SEO expert, this looks to be light on SEO (Search Engine Optimisation) related to phases people search for. As a result the link was found in the lonely spot on page 3 which is should be number 1.

Wouldn’t it be great if MDN had SEO focused content to support the excellent reference material it already has available? The PromoteJS movement has made a start but I think it needs a kick-start.

Who’s with me?

UPDATE (20/1/12):

In a moment of great timing, the Mozilla WebDev team started a AMA (Ask Me Anything) thread on Reddit. I pointed out the above comments and had some great responses from the team.

It turns out that MDN is a wiki so it’s in the community (and my hands) to make a difference.

You can read the comments here:

Leave a Reply

Your email address will not be published. Required fields are marked *