This commit is contained in:
Ilya Kantor 2015-08-17 12:41:38 +03:00
parent 48497f7d85
commit 8ba2c6b17c
23 changed files with 574 additions and 615 deletions

View file

@ -1,6 +1,6 @@
Ответы:
Answers:
<ol>
<li>Первым выполнится `big.js`, это нормальная последовательность выполнения подряд идущих скриптов.</li>
<li>Первым выполнится `small.js`, так как скрипты из-за `async` ведут себя совершенно независимо друг от друга, страница тоже от них не зависит.</li>
<li>Первым выполнится `big.js`, так как скрипты, подключённые через `defer`, сохраняют порядок выполнения относительно друг друга.</li>
<li>The first is `big.js`, that's a normal sequence for external `<script>` tags.</li>
<li>The first is `small.js`, because `async` makes script behave independently of each other and the page. The first to loads runs first.</li>
<li>The first is `big.js`, because "deferred" scripts keep relative execution order.</li>
</ol>

View file

@ -1,24 +1,24 @@
# Какой скрипт выполнится первым?
# Which script executes first?
[importance 4]
В примере ниже подключены два скрипта `small.js` и `big.js`.
In the questions below, there are two scripts: `small.js` and `big.js`.
Если предположить, что `small.js` загружается гораздо быстрее, чем `big.js` -- какой выполнится первым?
If we assume that `small.js` loads much faster compared to `big.js` -- which script executes first?
```html
<script src="big.js"></script>
<script src="small.js"></script>
```
А вот так?
What if we add `async`?
```html
<script async src="big.js"></script>
<script async src="small.js"></script>
```
А так?
What if we switch to `defer`?
```html
<script defer src="big.js"></script>