HighPerformanceWebSites

in the browsers cache matches the one on the server

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ment bigger •  Making JavaScript and CSS external implies more HTTP requests, but –  As HTML documents are not typically cached, so inlining JavaScript code will cause the same bytes to be downloaded on every page view •  Defining JavaScript externally is typically beler •  Download external files aoer onload window.onload = downloadComponents; function downloadComponents ( ) { var elem = document.createElement(“script”); elem.src = http://.../file1.js; document.body.appendChild(elem); ..... } Copyright 2009 - 2013 Horowitz 22 Rule 9: Reduce DNS lookups •  •  •  •  Typically each look up takes 20 – 120 milliseconds DNS lookups will block parallel downloads The operaOng system and the browser both have DNS caches As a general rule it is best to reduce the number of unique hostnames used in a web page Copyright 2009 - 2013 Horowitz 23 Minify JavaScript •  •  •  MinificaOon, or minify, is the process of removing all unnecessary characters from source code, without changing its funcOonality –  Unnecessary characters usually include: white space characters, new line characters, comments , and someOmes block delimiters used to add readability to code, but are not required for execuOon –  Minified code is especially useful for interpreted languages because it reduces the amount of data that must be transferred There are many programs that minify JavaScript code, see hlp://en.wikipedia.org/wiki/Minify (JSmin, packer, Google Closure Compiler) See these websites for examples of minificaOon: www.google.com purecss.io Copyright 2009 - 2013 Horowitz 24 Minified JavaScript •  Example...
View Full Document

Ask a homework question - tutors are online