1

The spec states "Scripts with async execute in the load-first order. Their document order doesn’t matter – which loads first runs first".

I've also read that async scripts should be completely independent.

In this scenario, is there no guarantee that non-async-script will be loaded before the async script loads?

<script src="non-async-script.js"></script>
<script src="async-script.js" async></script>
1

1 Answer 1

2

Historically, browsers would stop parsing the DOM until after the script tag is loaded.

Modern browsers do roughly the same thing, but to load resources in parallel it will read ahead in the DOM to find upcoming requests.

So to answer your question, the first script tag is not guaranteed to load before the second script, but it should execute before before the async script.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.