flash service

High_Performance_Web_Sites

Issue link: https://read.uberflip.com/i/1146286

Contents of this Issue

Navigation

Page 79 of 169

58 | Chapter 8: Rule 8: Make JavaScript and CSS External reuse rate, the argument is stronger for deploying your JavaScript and CSS as exter- nal files. If the reuse rate is low, inlining might make more sense. Typical Results in the Field In analyzing the tradeoffs between inlining versus using external files, the key is the frequency with which external JavaScript and CSS components are cached relative to the number of HTML documents requested. In the previous section, I described three metrics (page views, empty cache vs. primed cache, and component reuse) that can help you determine the best option. The right answer for any specific web site depends on these metrics. Many web sites fall in the middle of these metrics. They get 5–15 page views per user per month, with 2–5 page views per user per session. Empty cache visits are in the same range as Yahoo!: 40–60% of unique users per day have a primed cache, and 75–85% of page views per day are performed with a primed cache. There's a fair amount of JavaScript and CSS reuse across pages, resulting in a handful of files that cover every major page type. For sites that have these metrics, the best solution is generally to deploy the Java- Script and CSS as external files. This is demonstrated by the example where the external components can be cached by the browser. Loading this page repeatedly and comparing the results to those of the first example, "Inlined JS and CSS," shows that using external files with a far future Expires header is the fastest approach. Cacheable External JS and CSS http://stevesouders.com/hpws/external-cacheable.php Home Pages The only exception I've seen where inlining is preferable is with home pages. A home page is the URL chosen as the browser's default page, such as Yahoo! home page (http://www.yahoo.com) and My Yahoo! (http://my.yahoo.com). Let's look at the three metrics from the perspective of home pages: Page views Home pages have a high number of page views per month. By definition, when- ever the browser is opened, the home page is visited. However, there is often only one page view per session. Empty cache vs. primed cache The primed cache percentage might be lower than other sites. For security rea- sons, many users elect to clear the cache every time they close the browser. The next time they open the browser it generates an empty cache page view of the home page.

Articles in this issue

Links on this page

Archives of this issue

view archives of flash service - High_Performance_Web_Sites