Sometimes I need to do something what is not useful at all, just for the fun of it. Someone plays World of Warcraft as a hobby, someone listens to music, drinks, draws.. whatever. I make animations in javascript. It’s half fun and half learning. I can try new things, I can experiment, discover …and what is most important: I create.
After one rather bad day at work I needed to do something what I would really enjoy. Not that I don’t like my work, I do love it, but there are sometimes days that are just bad… I had a lot of small trivial tasks which were not very creative, but as one wise guy said “work is not supposed to be fun, work is supposed to be done”, so there was no other option than to do my job 🙂 So I completed my tasks and when I came home I started to work on this.
It is a rather useless but nice to look at piece of “art”. As I already mentioned I had two reasons to do this. One was to play with animations and the other was to learn how to use properly jQuery’s recommended plugin architecture. As it turned out the playful part did not last much long – just 50% of the time, I thought I would have it done in two evenings but I ran into issue with array manipulation and the whole thing took me eventually two times longer.
What I have learned during the development process? Never remove items from an array you are iterating on. You may end in an infinite loop, consume all CPU resources and freeze the browser. And more importantly that the public API of jquery plugins is a really nice feature. My script would be much more complicated without it. If you still write your plugins without public API (as I used to do) then go, read some documentation and try it yourself. It’s worth it.
And try my StarryNight plugin. It’s worth it too 🙂 More on it in the upcoming post. For now just check the demo and source code.