make sure DOM elements exist before connect to socket server