Question: How do I prevent JavaScript from blocking other JavaScript's from starting to download?

I have the following on my web site:

```
<html>
<body>
....
<script type="text/javascript" src="http://example.com/ex.js"></script>
<script type="text/javascript" src="http://google.com/google-maps.js"></script>
</body>
</html>

```

When I use the YSlow Firefox add-on, I can see from the network traffic tab that the `google.com/google-maps.js` JavaScript won't start downloading until `ex.js` has finishes downloading.

**Question**: How can I have both `ex.js` and `google-maps.js` begin downloading immediately and in parallel?

Answer: 
Use the `<script>` element's [`async` or `defer` attribute](http://www.webkit.org/blog/1395/running-scripts-in-webkit/):

> 
> Both `async` and `defer` scripts begin to
>  download immediately without pausing
>  the parser and both support an
>  optional `onload` handler to address the
>  common need to perform initialization
>  which depends on the script. The
>  difference between `async` and `defer`
>  centers around when the script is
>  executed. Each `async` script executes
>  at the first opportunity after it is
>  finished downloading and before the
>  `window`’s `load` event. This means it’s
>  possible (and likely) that `async`
>  scripts are not executed in the order
>  in which they occur in the page. The
>  `defer` scripts, on the other hand, are
>  guaranteed to be executed in the order
>  they occur in the page. That execution
>  starts after parsing is completely
>  finished, but before the `document`’s
>  `DOMContentLoaded` event.
> 
> 
> 

* `defer` is supported by IE4+, Firefox 3.5+, Chrome 2+, and Safari 4+.
* `async` is supported by Firefox 3.6+, Chrome 7+, and Safari 5+. (**No** IE support!)

`defer` is your best choice. Scripts will *download* in parallel and *execute* synchronously (in order). It's also better supported and more predictable than `async`. (See also [this very detailed analysis of `async`/`defer`](https://stackoverflow.com/questions/3952009/defer-attribute-chrome/3982619#3982619).)

```
<script defer type="text/javascript" src="script.js"></script>

```
The JavaScript files will always download in the order they are specified.