Ensure the DOM is ready before attaching handlers.