Add document check to avoid errors if loaded on the server.