The embedded JS has been moved to an ERB file and now accounts for the
possibility of the socket opening before the event is registered.