I've placed all of the physics logic inside an asm.js module. So on browsers that support asm.js, this should run more smoothly.
It uses a custom written helper for memory management, that you might find useful for small experiments. Check out the gist.
This demo is also available on codepen.io, which might be nicer for viewing the source code