Adopted RequireJS to avoid race conditions in dependencies.