Last active
August 25, 2020 08:55
-
-
Save 40thieves/ddfed60cd5a0d0f1251815e215b4cfe1 to your computer and use it in GitHub Desktop.
Demo of async script loading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Script loading</title> | |
</head> | |
<body> | |
Hello world | |
<script type="text/javascript" src="script.js" async></script> | |
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sleep(ms) { | |
var currentTime = new Date().getTime(); | |
// Force the thread to be blocked for ms | |
while (currentTime + ms >= new Date().getTime()) { | |
} | |
} | |
sleep(1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment