Keep the number of domains serving resources to a minimum
When a website or online service hosts a web page’s components across several domains, the browser has to establish an HTTP connection with every single one. Once the HTML page has been retrieved, the browser calls the sources as it traverses the DOM (Document Object Model).
Some resources are essential for the page to work. If they are hosted on another domain which is slow, it may increase the page’s render time. You should therefore, when possible, group all resources on a single domain.
The only exception to this is for static resources (style sheets, images, etc.), which should be hosted on a separate domain to avoid sending one or multiple cookies for each browser GET HTTP request. This reduces response time and unnecessary bandwidth consumption.
Only use the essential sections of JavaScript and CSS libraries
JavaScript libraries (e.g. jQuery, MooTools and YUI) and ready-to-use CSS frameworks (e.g. Bootstrap, skeleton, gumby and foundation) are excellent tools for building websites quickly because they meet all the most common requirements. On the other hand, we only use a small part of their capabilities, yet these frameworks and libraries are not based on a modular architecture, forcing the user to download the whole library in order to use only a small percentage of its features.
Whenever possible, it is best to do without these libraries (c.f. http://youmightnotneedjquery.com) or to only keep the parts which are actually used (c.f. http://getbootstrap.com/customize). If this is not feasible, download the source code and create a custom build that only includes the necessary components.








