JavaScript в нижней части/вершине веб-страницы?

Более не существующий веб-сайт whatsbetter.com использовал метод стиля Elo . Можно читать о методе в их FAQ на интернет-Архиве .

69
задан Peter Mortensen 31 December 2010 в 16:02
поделиться

4 ответа

It'll allow the web page to load visibly before executing JavaScript, which makes sense for things like Google Analytics, which don't need to happen before the page loads.

You may also want to look into things like jQuery, prototype, etc and attach to the "ready" handler, which executes JavaScript code after the DOM has been fully loaded, which is an appropriate place for much JavaScript code.

52
ответ дан 24 November 2019 в 13:52
поделиться

If you have static html content and a lot of javascript, it can make a difference in perceived page load time since the html will load first giving the user something to look at. If you don't have much javascript, or the existing page content relies on the javascript to be useful, then this is not as useful practically-speaking.

5
ответ дан 24 November 2019 в 13:52
поделиться

Yes, the page will load the content and render it before loading and executing javascript, and the page will, as a result, load faster.

3
ответ дан 24 November 2019 в 13:52
поделиться

Assuming you aren't running on a CDN or aren't serving your JS from a separate sub-domain or server, it will load synchronously and force your HTML content to wait until it has downloaded the files. By placing the JS at the bottom of your page before the closing tag, you are allowing the HTML to be parsed prior to loading the javascript. This gives the effect of faster page load times.

44
ответ дан 24 November 2019 в 13:52
поделиться
Другие вопросы по тегам:

Похожие вопросы: