In this post I will describe how I worked with coffeescript for developing the chrome extension of appsflyer.
First of all, coffee-watcher is a must IMO. What it does is to watch .coffee files in a folder and compile them to javascript files as they are saved. At first I thought, what’s the point? One of the nice features of dynamic languages is the no need for compilation. With coffeescript however it felt more like validation and less like compilation. It actually made me feel confident about the code I write, something that is lacking in javascript.
Since I created a chrome extension and in order to publish chrome extensions you generally zip compress a folder and upload it, by default the .coffee files will be packed as well. This can be easily handled by a script however I was lazy and just hardlinked (using the ln command, on windows you can use junction) the output javascript file from coffee-watcher to the extensions folder.
If you know something about chrome extensions, then you probably know that content scripts which are the components used to interact and manipulate the DOM of the webpage itself, are just javascript files. This means that adding html to the page can be a pain, unless you consider messing around with javascript string concatenation fun. With the help of coffeescript’s heredocs to hold html markup and Mustache when you need templating, this problem is easily solved.
After creating a chrome extension with the help of html5, I am convinced that the browser is a viable runtime environment for rich application. For the next projects I plan to use backbone.js or something similar.