1. A good rule of thumb is to load your static content from two or three domains.
You might want to have several domain aliases for your site. That
allows you to optimize download parallelism by simply adjusting the
domain names in your pages, without having to manage which content is in
which domain. Consider automating the process of assigning static files
to particular domains using an ASP.NET control adapter just be sure to use a consistent domain for each resource, to avoid unwanted cache misses.
2. To reduce round-trips, you should have as few script files as possible. You can arrange this by doing one or more of the following:
2. To reduce round-trips, you should have as few script files as possible. You can arrange this by doing one or more of the following:
3. Mid-document script includes can cause the browser to delay rendering the page until after the script file arrives. From a performance perspective, it’s better to place your includes at the end of your HTML when you can. A common reason for using mid-document script includes is to insert HTML into the page using
document.write()
.
- Instead of
document.write()
, useinnerHTML
or direct DOM manipulation, which you can do late in the HTML- If you can’t avoid
document.write()
(such as with scripts from third-parties), then instead of using multiplefiles, either:
- Wrap the script with absolute positioning and run it late in the file, or
- Run the script in a hidden
, and then move the contents of the
into its desired location by manipulating the DOM using JavaScript4. Avoid document.write()
5.Request Images and Other Objects After the Page Loads
No comments:
Post a Comment