JavaScript efficiency update

that was surprisingly easy and should work... we'll have to test it in
class, but I'm happy with it. Also still need to add delete, but that
should be really easy so it can wait.