modified for better testing

added flag for indicating that javascript listeners are loaded