You are here:Home arrow Home arrow Separating CSS and JS from HTML
  • Narrow screen resolution
  • Wide screen resolution
  • Decrease font size
  • Default font size
  • Increase font size
  • default color
  • green color
  • blue color

Separating CSS and JS from HTML

Monday, 29 June 2009

Increasing cacheability of a website is an important step in website performance optimization. It allows website visitors to store non-changing parts of your website in browser cache for faster access.

Using external files basically results in faster page response times because JavaScript and CSS files are cached by browsers. JavaScript and CSS code that is inlined in webpages gets downloaded every time the HTML document is requested. This reduces the number of HTTP requests that are needed, but increases the size of the HTML document. On the other hand, if the JavaScript and CSS are in external files cached by the browser, the size of the HTML document is reduced without increasing the number of HTTP requests.

The key factor, then, is the frequency with which external JavaScript and CSS components are cached relative to the number of HTML documents requested. This factor, although difficult to quantify, can be gauged using various metrics. If users on your site have multiple page views per session and many of your pages re-use the same scripts and stylesheets, there is a greater potential benefit from cached external files.

Next >


Your server OS of choise


Related Articles