Load a Javascript file, but cancel if it takes too long?
问题 Anyone have a good way to load a JS file but cancel loading it if it takes too long? I'm thinking something like this, hypothetically: <script type="text/javascript" cancel_after="2000" src="myfile.js"></script> The script is code that needs to get loaded in the head, because it replaces elements on the page, and so the browser needs to block while loading it. But in case the server takes too long to respond, I'd like to be able to have the browser proceed without loading the script. 回答1: Use