outsource events + fix login.js embed