Using Cookie Clicker to learn JavaScript?

What is Cookie Clicker?

For those who don’t know Cookie Clicker is a game about clicking and collecting cookies. That’s it. I consider it to be in the same sort of vain as many other Cow Clicker style games, but not quite as bad. It’s a simple nice waste of time and a good example of a HTML 5 Game that doesn’t use the canvas tag (at least not yet).

Cookie Clicker

What do you do in it?

The main thing you do in the game is click things to gain cookies or increase the rate at which you accumulate them. There’s no real money store (thank god) and no real way of getting ahead of someone whose started before you without cheating horribly and using the JavaScript Console. And the fact you can edit and fiddle with the game in such a way is the subject I’d like to discuss.

What’s Special About it?

Because it’s made using HTML and JavaScript (and isn’t minified or obfuscated in any way) you can take it apart and learn from it, devise the best strategy or analyse how the underlying systems work. In my eyes this could be a gold mine for teaching people JavaScript, HTML and some basic web programming. You could use it as a way of introducing concepts like variables and later methods to students.

For example typing: Game.cookies into the console will cause it to output the amount of cookies you currently have in the game.

I use Firebug in Firefox

I use Firebug in Firefox

And that’s just one thing you can find out, the source code is littered with values that would be useful or interesting for players to see.

With access to the JavaScript and HTML you can introduce someone slowly to how clicking buttons effects its inner state, and later actually get them to write some scripts to assist them in playing the game or downright do everything for them.

I’ve actually written a small bot that can actually play the game just as well as I can. And I’d love to see others do the same to see how much better or different they can make things.

In fact that’s my challenge to those reading this; make a bot that can play Cookie Clicker.

Below is my bot (shared on github) for inspiration, bookmarklet is below, simply drag it to your favourites and click it when you are on the Cookie Clicker game to see it in action:

Cookie Clicker Bot

Sorry for the short and long delay between blog posts, will likely be more coming soon!


  1. JD says:

    Try executing Game.Earn(9999999999) from the console in your browser 😉

  2. nomiad says:

    sry, but the cookieclicker source and way it was coded ist not structured in any way. Its the work of a new coder. Read the source, it shivers my bones when i read that spagetti code.

Leave a Reply