Added support for require.js, and migrated code base superficially to use it.