Socket connect before document ready