Top Banner
Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - [email protected]
53

Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - [email protected].

Dec 27, 2015

Download

Documents

Arline Hunter
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Keeping Front End Dependencies Under Control

Rachel LehmanTechnical Team at Interfolio, Inc.

@raelehman - [email protected]

Page 2: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 3: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 4: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 5: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 6: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 7: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

What are the dependencies?

JavaScriptCSS

Images

Page 8: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

5 Simple Steps1. Organize and plan2. Location matters3. Load smart, load once4. Maximize caching opportunities5. Optimize, minify and compress

http://developer.yahoo.com/performance/rules.html

Page 9: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

JavaScript

Page 10: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Organization and Planning

Spry GWTjQuery Prototype YUI EXT.js* Dojo

Jeremy Keith introduced this concept

Page 11: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Classic Pairings

• CF + EXT• CF + Spry• jQuery + jQuery UI• YUI + … YUI• Prototype & script.aculo.us

Page 12: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Externalize Scripts, at the Bottom

Page 13: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

http://24ways.org/2007/keeping-javascript-dependencies-at-bay

Page 14: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

http://developer.yahoo.com/yui/yuiloader/

Page 15: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Server-Side Script Bundling

Page 16: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Minify & Compress

• Minify everything for production– Strip out white space, comments, extra characters

to minimize file size– Optionally, obfuscate your code

• Gzip files over 1 or 2k– Serve compressed files from the server to browsers

that support it– Don’t compress files already compressed (PDF,

images)http://developer.yahoo.com/yui/compressor/

Page 17: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Cache

• Use external scripts• Use Google-hosted libraries for caching

benefit• Set expires headers on common scripts• Configure entity tags (e-tags) on clusters

http://code.google.com/apis/ajaxlibs/http://www.jesscoburn.com/archives/2008/10/02/quickly-configure-or-disable-etags-in-iis7-or-iis6/

http://www.askapache.com/htaccess/apache-speed-etags.html

Page 18: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Directory > HTTP Response Headers > Set Common Headers

http://technet.microsoft.com/en-us/library/cc770661(WS.10).aspx

Page 19: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

In .htaccess

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Expires “Fri, 13 Aug 2010 20:00:00 GMT" </FilesMatch>

http://www.askapache.com/htaccess/apache-speed-expires.html

Page 20: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

In ColdFusion, with <cfheader>

Page 21: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

http://www.jslint.com/

Page 22: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

CSS | Style Sheets

Page 23: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Externalize CSS, at the Top

Page 24: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 25: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Minify

Page 26: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

cssInclude Custom Tag

Page 27: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Please!

• Comment your CSS!!!• Especially hacks, workarounds and

redunancies• Groups of related styles (search hooks)

Page 28: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 29: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 30: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Reset CSS• Comprehensive:

Eric Meyerhttp://meyerweb.com/eric/tools/css/reset/reset.css

• Basic:YUI http://yuilibrary.com/

Page 31: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 32: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 33: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 34: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Toward Modular CSS

• Build a grid system http://24ways.org/2008/making-modular-layout-systems

• BlueprintCSS• 960 Grid System (960gs)• YUI Grids

Page 35: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 36: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 37: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 38: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Working with Multiple Files

• Good – organize by purpose– Framework (grids, reset, typography reset/base)– Core/Skin (application-specific)– Hacks/browser-specific (thanks IE)– [Application sections (forms, edit, admin, etc)]

• Problematic – organize by rule type*– Colors / images (colors/background images only)– Typography (font definitions only)– Positioning (positioning definitions only)

Page 39: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Images

Page 40: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Organization and Planning

Page 41: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Loading Smart

• Set expires headers on common elements like logos and navigation

Page 42: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Minimize File Size

• PNG files are your friend• JPEGs for photos and continuous tone images• GIFs for simple illustrations, logos, solid color• Use the comparison view of your image editor• Fireworks generally better than Photoshop for

file size and quality• SmushIt removes extra non visual data

Page 43: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.
Page 44: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Minimize Your Image Needs

• Use CSS Sprites for nav tabs, buttons, icons• Do you really need an image? Use CSS3

(corner radius, RGBa) for non-functional enhancements

• Trim images to minimal dimensions• Use small tiled images, but not too small

Page 45: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

file:///C:/Users/Rae/Workspace2/cfunited09/toolbar.html

Page 46: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

file:///C:/Users/Rae/Workspace2/cfunited09/toolbar.html

Page 47: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

General Advice and Tools

Page 48: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Choosing Libraries

• Don’t worry as much about what’s popular as what works for your project and your philosophy

• Build on existing skills• Know how to read your stats to decide what to

support

Page 49: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Essential Tools

• Firebug• YSlow• Firefox Web developer

toolbar• Safari Web Developer

Tools• IE Web Developer Tools

Extension

Page 50: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

May Work for You…• CF– Scriptalizer

http://www.aaronjlynch.com/blog/2008/07/09/Problem-WAY-too-many-javascript-files-Solution-cfscriptalizer orhttp://scriptalizer.com/

–Combine.cfchttp://combine.riaforge.org/

• CSS– Blueprint.css

http://www.blueprintcss.org/ – 960.gs

http://960.gs – YUI Grids / Fonts / Reset

http://developer.yahoo.com/yui/ – Eric Meyer’s reset.css

http://meyerweb.com/eric/tools/css/reset/

– Andy Clarke’s Universal IE6 Style Sheethttp://code.google.com/p/universal-ie6-css

• JS– AJILE

http://ajile.net/

– JSLinthttp://www.jslint.com

Page 51: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Summary1. Organize and plan2. Location matters3. Load smart, load once4. Maximize caching opportunities5. Optimize, minify and compress

http://developer.yahoo.com/performance/rules.html

Page 52: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Q & A

Come tohttp://www.riaunleashed.com/

Page 53: Keeping Front End Dependencies Under Control Rachel Lehman Technical Team at Interfolio, Inc. @raelehman - raelehman@gmail.com.

Rachel Lehman

@[email protected]

http://rmaxim.blogspot.com