Тег сценария - асинхронный и отложенный

У меня есть пара вопросов об атрибутахasync & Амп;defer для<script> тег, который, насколько я понимаю, работает только в браузерах HTML5.

На одном из моих сайтов есть два внешних файла JavaScript, которые в данный момент находятся над</body> тег; во-первых Источник от Google, а второй является локальным внешним скриптом.

With respects to site load speed

Is there any advantage in adding async to the two scripts I have at the bottom of the page?

Would there be any advantage in adding the async option to the two scripts and putting them at the top of the page in the <head>?

Would this mean they download as the page loads? I assume this would cause delays for HTML4 browsers, but would it speed up page load for HTML5 browsers? Using <script defer src=... Would loading the two scripts inside <head> with the attribute defer the same affect as having the scripts before </body>? Once again I assume this would slow up HTML4 browsers. Using <script async src=...

Если у меня есть два сценария сasync включен

Would they download at the same time? Or one at a time with the rest of the page? Does the order of scripts then become a problem? For example one script depends on the other so if one downloads faster, the second one might not execute correctly etc.

Наконец, лучше ли мне оставить все как есть до тех пор, пока HTML5 не станет более распространенным?

Ответы на вопрос(7)

Ваш ответ на вопрос