Pro JavaScript Performance.pdf
(
35450 KB
)
Pobierz
www.it-ebooks.info
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
www.it-ebooks.info
Contents at a Glance
About the Author ..................................................................................................................
ix
About the Technical Reviewer ...............................................................................................
x
Acknowledgments ................................................................................................................
xi
Chapter 1: What is Performance ...........................................................................................
1
Chapter 2: Tools and Technology to Measure and Impact Performance ...........................
13
Chapter 3: WPTRunner—Automated Performance Monitoring and Visualization... .........
43
Chapter 4: perfLogger—JavaScript Benchmarking and Logging .....................................
65
Chapter 5: Looking Forward, a Standard for Performance ................................................
83
Chapter 6: Web Performance Optimizations.....................................................................
109
Chapter 7: Runtime Performance ......................................................................................
139
Chapter 8: Balancing Performance with Software Engineering Best Practices... ..........
175
Index ..................................................................................................................................
203
iv
www.it-ebooks.info
Chapter 1
■ ■ ■
What is Performance
Performance
refers to the speed at which an application functions. It is a multifaceted aspect of quality.
When we’re talking about web applications, the time it takes your application to be presented to your users
is what we will call
web performance
. The speed at which your application responds to your users’
interactions is what we’ll call
runtime performance
. These are the two facets of performance that we will be
looking at.
Performance in the context of web (and especially mobile web) development is a relatively new
subject, but it is absolutely overdue for the attention it has been getting.
In this book we will explore how to quantify and optimize JavaScript performance, in the context of
both web performance and runtime performance. This is vitally important because JavaScript is
potentially the largest area for improvement when trying to address the total performance of your site.
Steve Souders, architect of both YSlow and PageSpeed, and pioneer in the world of web performance, has
demonstrated this point in an experiment where he showed an average performance improvement of 31%
when removing JavaScript from a sample of web sites.
1
We can completely remove any JavaScript from our
site as Steve did in his experiment, or we can reine how we write JavaScript and learn to measure the
eficiencies in what we write.
It’s not realistic to remove JavaScript from our front-end, so let’s look at making our JavaScript more
eficient. Arguably even more important, let’s look at how we can create automated tools to track these
eficiencies and visualize them for reporting and analysis.
Web Performance
Sitting with your laptop or holding your device, you open a web browser, type in a URL and hit Enter, and
wait for the page to be delivered to and rendered by your browser. The span of time that you are waiting for
the page to be usable depends on web performance. For our purposes we will deine web performance as
an overall indicator of the time it takes for a page to be delivered and made available to your end user.
There are many things that inluence web performance, network latency being the irst. How fast is
your network? How many round trips and server responses are needed to serve up your content?
To better understand network latency, let’s irst look at the steps in an HTTP transaction (Figure 1.1).
When it requests a URL, whether the URL for a web page or a URL for each asset on a web page, the
browser spins up a thread to handle the request and initiates a DNS lookup at the remote DNS server. This
allows the browser to get the IP address for the URL entered.
1
http://www.stevesouders.com/blog/2012/01/13/javascript-performance/
1
www.it-ebooks.info
Chapter 1
■
What is performanCe
Browser
DNS Server
Server
DNS Lookup
DNS Reply
SYN
SYN-ACK
ACK
HTTP GET
HTTP Response
2XX | 3XX | 4XX | 5XX
FIN
FIN-ACK
ACK
Figure 1-1.
Sequence diagram of network transactions in a request for a web page and repeated for each
remote -object included in a web page
2
www.it-ebooks.info
Plik z chomika:
ideon410
Inne pliki z tego folderu:
Professional JavaScript for Web Developers, 3rd Edition.pdf
(53510 KB)
Pro JavaScript Performance.pdf
(35450 KB)
JavaScript & jQuery- The Missing Manual, 3rd Edition.pdf
(23147 KB)
JavaScript Enlightenment.pdf
(7454 KB)
JavaScript Web Applications.pdf
(10088 KB)
Inne foldery tego chomika:
Crystal Reports
htlm5
Jquery
Mieszane
PHP -MySQL
Zgłoś jeśli
naruszono regulamin