简体   繁体   中英

javascript inside the page and not in external js file

I was wondering why hotmail, facebook and google write javascript inside the html page and not in an external JavaScript file? Doesn't this increase the page size and the amount of JavaScript that's not cached in the browser?

It may depend on how the page is created. While it does have disadvantages, it does reduce the number of server requests, which may also be an issue.

Some sites with very hight traffic have to reduce the number of requests because they are quite heavy on the webserver. It's the same reason why people use CSS sprite , lower the number of requests. Have a look of Steve Souders work on web performance especially to his 12 rules for performance

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM