Slide 1

Slide 1 text

JQUERYTO MARCH, 2014 Justin Tulloss [email protected] @justin_tulloss Structure over Framework Thoughts on building web clients

Slide 2

Slide 2 text

2 Overview • What we’re building • Structuring an application • Optimizing developer productivity • Optimizing consumer experience

Slide 3

Slide 3 text

What we’re building

Slide 4

Slide 4 text

4 We’re building a codebase • Many people are going to touch this code • From adding features to fixing bugs to massive refactors • Even more people will need to read the code • Code review! • Old code never dies • Single page application • Data driven

Slide 5

Slide 5 text

" Structuring an application

Slide 6

Slide 6 text

6 What’s in an application? • Services • API, analytics, loading code, DOM manipulations, animations, perf tracking, etc. • Models (View Models) • Data • View specific information inferred from the data • UI Components • Rely on services and models • Contain markup, styling, and behavior

Slide 7

Slide 7 text

7 Services at Rdio • Globally available • Services implement a simple state machine • Stopped, starting, ready • Indicate when they’re available to be used, cannot be used until they say they’re ready • Can depend on other services and libraries, but nothing else (no UI components) • Multiple classes can provide the same service

Slide 8

Slide 8 text

8 UI Components • Package of markup, styling, and behavior • Form the tree of the application • Have a standardized lifecycle • Have a model, but don’t care too much what’s in it (just that it’s the right type) • Responsible for keeping the UI up to date (data-binding or rerendering) • Can depend on models, services, and other libs • Can declare other component dependencies and instantiate those components

Slide 9

Slide 9 text

9 Strict interactions between components Child Component Parent Component API Events

Slide 10

Slide 10 text

10 Models • Provide data • Provide APIs for manipulating that data • Provide APIs for gaining greater context around the data • For instance, how do I say “Share this model” in the UI? • Can rely on services for achieving the above goals

Slide 11

Slide 11 text

# Optimizing developer productivity

Slide 12

Slide 12 text

12 Principles • Only one way to do things • Inspecting the DOM should point the developer to the source of the elements • CSS scoping happens automatically • Declare program dependencies, not file dependencies • Strong patterns around what can be changed and what can be changed with caution • Documentation, method naming, tests, etc

Slide 13

Slide 13 text

13 Example: Catalog.Album

Slide 14

Slide 14 text

14 A Component

Slide 15

Slide 15 text

15 Component Markup

Slide 16

Slide 16 text

16 Component Styles

Slide 17

Slide 17 text

17 Component Behaviors

Slide 18

Slide 18 text

18 Developer Worries • Write your markup • Describe your model • Write/test your behaviors • Style your component • Ship it!* • Find kegerator

Slide 19

Slide 19 text

19 Developer Non-worries • Loading of markup/styles/behaviors • Loading of dependencies • Optimizations related to rendering, animation, caching, packaging, everything except the specific job of the component • Updating code

Slide 20

Slide 20 text

$ Optimizing consumer experience

Slide 21

Slide 21 text

21 What to optimize? • Measure Everything • The product! • How well the product works

Slide 22

Slide 22 text

22 How well the product works • Perception is what counts • Time to app perceived as loaded • Time to first X • Interactions as the user continues to use the product

Slide 23

Slide 23 text

23 How little can be loaded? Really fast Load Time # of Features

Slide 24

Slide 24 text

24 Easy win: Caching + CDNs • CDNs are cheap and easy now, use them • Cache files with aggressive cache headers (public, 1 year max age) • Put files MD5 signatures in file names • Ideal is that repeat users only have to load code that has changed • Balanced against more requests for first time visitors

Slide 25

Slide 25 text

25 Example: Rdio anonymous landing page

Slide 26

Slide 26 text

26 Optimizing Interactions • Measure! • Have services take care of performance sensitive global behaviors • Have components take care of performance sensitive local behaviors • IE, Grids

Slide 27

Slide 27 text

Join Us • We love music and JavaScript • Canadian friendly! • It’s 22° C right now

Slide 28

Slide 28 text

Questions

Slide 29

Slide 29 text

29 Thanks! • Organizers have been fantastic • Thanks to Rdio for letting me come out and talk to all you fine folks • dancewithlight and 500px for SF skyline photo (http://500px.com/photo/58946980)