More reliable document ready detection.