Skip to content

Instantly share code, notes, and snippets.

@40thieves
Last active August 25, 2020 08:55
Show Gist options
  • Save 40thieves/ddfed60cd5a0d0f1251815e215b4cfe1 to your computer and use it in GitHub Desktop.
Save 40thieves/ddfed60cd5a0d0f1251815e215b4cfe1 to your computer and use it in GitHub Desktop.
Demo of async script loading
<!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>
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