[js] Restructing the frontend into AMD modules with commonjs require() statements.
(Mostly) All explicit dependencies declared. No more huge block of script files!