After consulting with several companies on performance related issues, it became clear that one of the biggest performance issues facing websites today is the sheer amount of JavaScript needed to power the page. The demand for more interactive and responsive applications has driven JavaScript usage through the roof. It’s quite common for large sites to end up with over 1 MB of JavaScript code on their page even after minification. But do today’s web applications really need that much JavaScript?
13. Atwood’s Law
Any application that can be
written in JavaScript,
will eventually be written in
JavaScript.
http://www.codinghorror.com/blog/2007/07/the-principle-of-least-power.html
29. “It's no longer good
enough to build web
apps around full page
loads and then
progressively enhance
them to behave more
dynamically.”
- throneofjs.com
32. “To improve the twitter.com experience for everyone,
we've been working to take back control of our front-end
performance by moving the rendering to the server.
This has allowed us to drop our initial page load times
to 1/5th of what they were previously and reduce
differences in performance across browsers.”
https://blog.twitter.com/2012/improving-performance-twittercom
33. “Our thesis [was] if we have a JavaScript runtime on the server, we should be able to
pull most of this application logic back down to the server in a way that can be
shared with the client. Your great new product can run on both sides of the wire, serving
up real HTML on first pageload, but then kicking off a client-side JavaScript app.”
http://nerds.airbnb.com/weve-launched-our-first-nodejs-app-to-product
34. “…we re-launched our Mobile Web site using this new stack, replacing the Backbone.js
+ Rails stack that it used previously...It looks exactly the same as the app it
replaced, however initial pageload feels drastically quicker because we serve up real
HTML instead of waiting for the client to download JavaScript before rendering. Plus, it
is fully crawlable by search engines.”
http://nerds.airbnb.com/weve-launched-our-first-nodejs-app-to-product
42. https://support.google.com/analytics/answer/1008080?hl=en
“Once you find the code snippet, copy and paste it into your web page, just before the
closing </head> tag*. If your website uses templates to generate pages, enter it just
before the closing </head> tag in the file that contains the<head> section.”
74. What the JavaScript does
1. Look for tabviews via data-nui-type
2. Read UI state based on classes
3. Annotate DOM with additional information
4. Use event delegation to watch for user
interaction
5. Swap classes to react to events
78. Server HTML CSS JavaScript
Rendering
HTML
Constructing
URLs
Calculating
dependencies
Redirecting
Document
structure
Native
functionality
Accessibility
Layout
Colors
Visibility
Animation
Handling
Events
Ajax
Changing UI
79. The 4 JavaScript Load Times
• Primarily analytics
• Small seed filesIn <head>
• Anything needed by page load
• Minimal as possibleBefore </body>
• Anything needed soon afterAfter page load
• Anything needed as a result of user actionOn demand
80. JS Libraries and Economies of Scale
Cost per
JavaScript
component
Number of components