Skip to content

Instantly share code, notes, and snippets.

@hritik5102
Last active April 8, 2024 20:21
Show Gist options
  • Save hritik5102/a600df69e78982f5fb9aa84b3a0899cd to your computer and use it in GitHub Desktop.
Save hritik5102/a600df69e78982f5fb9aa84b3a0899cd to your computer and use it in GitHub Desktop.
Normal Script Loading - Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Async vs Defer</title>
<script>
console.log('Start HTML Parsing');
</script>
</head>
<body>
<p>Hello, World</p>
<!-- external script -->
<script src="index.js"></script>
<div class="content">
<span>Span element</span>
</div>
<script>
console.log('End HTML Parsing');
</script>
</body>
</html>
let sum = 0;
for (let i = 0; i < 10000000; i++) {
sum += i;
}
console.log('Script is Executed, Sum is : ', sum);
window.addEventListener('DOMContentLoaded', function () {
console.log('DOMContentLoaded event fire');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment