Speed Loading

  • 1,898 views
Uploaded on

 

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,898
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
19
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • tonight im going to cover some ways to get your pages to load faster. specifically, pages with a larege amount of javascript and css like the ones we build when creating highly interactive web sites or web appiications.
  • I would imagene you have heard of many if not all of these things before. They are commonly used for the kind of javascript development we to do nowadays. What im seeing however, is that few people actually implement them.
  • The single greatest speed savings lies in concatenating your javascript and css files. when we have multiple javascript files, the browser does something called script blocking, which is where it forces each javascript file to be completely downloaded before the next is started.  each request also carries with it the overhead of header information used for the http request. we can elimnate this as well by concatenation our javascript and css. There is a tool out there called JSBuilder that lets us do this, which we will cover in a a moment, but first lets look at script blocking and why it sucks so much.

Transcript

  • 1. Speed Loading Tactics for a quicker initial page load
  • 2. What to do First
      • Concatenate
      • Remove Fluff
      • GZip
      • Cache
      • Sprite
  • 3. Concatenation
      • Multiple JavaScript files == slow
        •   Script blocking
        •   Overhead for each request 
        •   Image loading is delayed 
    •  
    •  
      • Tools
        •   JSBuilder
        •   Also Removes Fluff
    •  
  • 4. Script Blocking
    • Each script waits for the previous
  • 5. HTTP Negotiation combined file contents 2.26s negotiation 0.37s combined negotiation 2.37s file contents 1.1s
  • 6. Using JSBuilder
    • Demo time!
  • 7. GZip Compression
    • Can you say Kick Ass!
  • 8. Reasons to use GZip
    •  
    • 60% smaller files
      • Server compresses on the fly
      • Browser decompresses
    •  
    •  
    •  
    • Notes
      • Works for css as well
      • Don't use on compressed content (jpg, gif, png, etc)
  • 9. GZip Results
    • Reduced download time by 45%
  • 10. Enabling GZip
    •  
    • Load Apache2 Module in httpd.conf
    •  
    • LoadModule deflate_module modules/mod_deflate.so
    •  
    • .htaccess or httpd.conf
    •  
    • <IfModule mod_deflate.c>   SetOutputFilter DEFLATE   AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/javascript application/x-javascript </IfModule>
    •  
    •  
    •  
    • Note: Uses 'gzip' routine, not MS 'deflate' routine
  • 11. Caching
      • Set Cache-Control headers
      • Sends expiration date in response
      • Browser reads expiration date
  • 12. Cache Content
    • Cached files not downloaded on re-visit
  • 13. Enabling Cache/Expire
    • Load Apache2 Module in httpd.conf
    •  
    • LoadModule expires_module modules/mod_expires.so LoadModule headers_module modules/mod_headers.so
    •  
    • .htaccess or httpd.conf
    •  
    • <IfModule mod_expires.c> ExpiresActive On ExpiresByType text/css &quot;access plus 30 days&quot; ExpiresByType text/javascript &quot;access plus 7 days&quot; ExpiresByType application/x-javascript &quot;access plus 7 days&quot; ExpiresByType application/javascript &quot;access plus 7 days&quot; ExpiresByType image/x-icon &quot;access plus 7 days&quot; ExpiresByType image/vnd.microsoft.icon &quot;access plus 7 days&quot; ExpiresByType image/png &quot;access plus 30 days&quot; ExpiresByType image/gif &quot;access plus 30 days&quot; ExpiresByType image/jpeg &quot;access plus 30 days&quot; ExpiresByType image/jpg &quot;access plus 30 days&quot; ExpiresByType application/x-shockwave-flash &quot;access plus 30 days&quot; </IfModule>
  • 14. Bust The Cache
      • Update the users files
    •  
    • Version numbers embedded in file name
    •  
    • YourCoolJavaScript. 2.2 .js becomes YourCoolJavaScript. 2.3 .js
    •  
    • Version number as query string
    • YourCoolJavaScript.js?ver= 2.2 becomes YourCoolJavaScript.js?ver= 2.3
  • 15. Sprites
      • Combine multiple images into one
      • Use CSS to display image by coordinates
  • 16. Sprite Sample
    • Single Image (Sprite) - 2.5k
    •  
    • Multiple Images - 6.1k total
  • 17. Sprite Results
    • 60% faster
  • 18. General Notes
      • CSS Always goes in the head
        • Other locations will delay page rendering
      • GZip can actually be slower on old server/client hardware
  • 19. Tools
    • JSBuilder
    • http://code.google.com/p/js-builder/
    •  
    • IBM Page Detailer
    • http://www.alphaworks.ibm.com/tech/pagedetailer
    • Live HTTP Headers
    • http://livehttpheaders.mozdev.org/installation.html