Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

This is the companion code to my "7 Steps to Better Javascript" presentation.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 public
Octocat-spinner-32 spec
Octocat-spinner-32 views
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 config.ru
Octocat-spinner-32 server.rb
README.rdoc

Javascript Refactoring Demo

What is this?

This super-simple application is a demo that accompanies my 7 Steps to Better Javascript talk. The intent is to walk you step-by-step through 7 Javascript refactorings in order to update your chat.js from 0_original.js to 7_reuse_with_setup_params.js.

During my talk I will be explaining how to approach each refactoring and what its benefits are. The same information is provided in comments at the top of each refactored javascript file.

Please note that I used my Web Sockets demo as a starting point (github.com/chrisjpowers/web_sockets_demo), so the Pusher library is an integral part of this demo as well.

How do I get started?

I'm working with the understanding that you have your favorite flavor of Ruby installed and working. Assuming that's true…

Clone this repository:

$ git clone git://github.com/chrisjpowers/js_refactoring_demo.git
$ cd js_refactoring_demo

Make sure Rubygems is up to date and you have Bundler installed:

$ gem update --system
$ gem install bundler

Install dependencies with Bundler:

$ bundle install

Start the app server:

$ ruby server.rb

Check out the demo at localhost:4567

Start the test server:

$ rake jasmine

Run the test suite by browsing to localhost:8888

That worked, now what?

Start refactoring! I've laid out seven steps to help get you moving in the right direction, but it's up to you to decide the best techniques to use. I guarantee that developers will think that I've refactored too much, and others will say that I haven't done enough – so what do you think?

Um, a little help?

Just in case you're not familiar with one of these libraries, here are some docs:

Something went wrong with that request. Please try again.