Slide 1

Slide 1 text

Eric Ferraiuolo, YUI @ericf Y.App URLs, Navigation, Routing, & Views

Slide 2

Slide 2 text

URLs Core to an App, Part of the UI

Slide 3

Slide 3 text

http://example.com/foo/ http://example.com/#/foo/ http://example.com/#!/foo/

Slide 4

Slide 4 text

http://example.com/foo/ http://example.com/#/foo/ http://example.com/#!/foo/

Slide 5

Slide 5 text

Who’s Data?

Slide 6

Slide 6 text

Everyone’s?

Slide 7

Slide 7 text

Everyone’s? Use Full-path URLs

Slide 8

Slide 8 text

Server’s Ability?

Slide 9

Slide 9 text

Dumb Server?

Slide 10

Slide 10 text

Dumb Server? Use Hash-based URLs

Slide 11

Slide 11 text

Initial State The First Thing a User Sees

Slide 12

Slide 12 text

Rendering /foo/

Slide 13

Slide 13 text

http://example.com/foo/

Slide 14

Slide 14 text

http://example.com/foo/ Fast Puppy! /foo/ HTML

Slide 15

Slide 15 text

http://example.com/foo/ Fast Puppy! /puppy.jpg IMG /foo/ HTML

Slide 16

Slide 16 text

Rendering /#/foo/

Slide 17

Slide 17 text

http://example.com/#/foo/

Slide 18

Slide 18 text

http://example.com/#/foo/ / HTML

Slide 19

Slide 19 text

http://example.com/#/foo/ / /app.js JavaScript HTML

Slide 20

Slide 20 text

http://example.com/#/foo/ / /app.js HTML /foo/ JSON JavaScript Slow Puppy :(

Slide 21

Slide 21 text

http://example.com/#/foo/ / /app.js HTML /foo/ JSON JavaScript Slow Puppy :( /puppy.jpg IMG

Slide 22

Slide 22 text

Render Initial State on the Server, It’s Faster!

Slide 23

Slide 23 text

5x Faster Twitter is Moving Away From /#!/

Slide 24

Slide 24 text

Enhance …Progressively

Slide 25

Slide 25 text

pjax pushState + Ajax

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Removes Unnecessary Full Page Loads

Slide 28

Slide 28 text

Automatically Handles Clicks

Slide 29

Slide 29 text

Does Not Break Browser's Conventions

Slide 30

Slide 30 text

Client-side Routing Ful lling Requests on the Client

Slide 31

Slide 31 text

Data in Memory -> No HTTP Request

Slide 32

Slide 32 text

Seamlessly Support /foo/ & /#/foo/

Slide 33

Slide 33 text

Responding to URL Changes

Slide 37

Slide 37 text

Y.App

Slide 38

Slide 38 text

Y.App Y.PjaxBase Y.Router Y.View

Slide 39

Slide 39 text

Y.App Navigation Routing App View

Slide 40

Slide 40 text

Y.App Navigation Routing App View View Management Transitions Server Coordination

Slide 41

Slide 41 text

Hello World Y.App

Slide 42

Slide 42 text

Hello World Y.App Hello World!

Slide 43

Slide 43 text

Hello World Y.App Y.HelloView = Y.Base.create('helloView', Y.View, [], { render: function () { var name = this.get('name'); this.get('container').set('text', 'Hello ' + (name || 'World') + '!'); return this; } }); var app = new Y.App({ views: { hello: {type: 'HelloView'} } }); app.route('/', function (req) { this.showView('hello'); }); app.route('/:name', function (req) { this.showView('hello', {name: req.params.name}); }); app.render().navigate('/eric');

Slide 44

Slide 44 text

Hello World Y.App Y.HelloView = Y.Base.create('helloView', Y.View, [], { render: function () { var name = this.get('name'); this.get('container').set('text', 'Hello ' + (name || 'World') + '!'); return this; } }); var app = new Y.App({ views: { hello: {type: 'HelloView'} } }); app.route('/', function (req) { this.showView('hello'); }); app.route('/:name', function (req) { this.showView('hello', {name: req.params.name}); }); app.render().navigate('/eric');

Slide 45

Slide 45 text

Hello World Y.App Y.HelloView = Y.Base.create('helloView', Y.View, [], { render: function () { var name = this.get('name'); this.get('container').set('text', 'Hello ' + (name || 'World') + '!'); return this; } }); var app = new Y.App({ views: { hello: {type: 'HelloView'} } }); app.route('/', function (req) { this.showView('hello'); }); app.route('/:name', function (req) { this.showView('hello', {name: req.params.name}); }); app.render().navigate('/eric');

Slide 46

Slide 46 text

Hello World Y.App Y.HelloView = Y.Base.create('helloView', Y.View, [], { render: function () { var name = this.get('name'); this.get('container').set('text', 'Hello ' + (name || 'World') + '!'); return this; } }); var app = new Y.App({ views: { hello: {type: 'HelloView'} } }); app.route('/', function (req) { this.showView('hello'); }); app.route('/:name', function (req) { this.showView('hello', {name: req.params.name}); }); app.render().navigate('/eric');

Slide 47

Slide 47 text

Hello World Y.App Y.HelloView = Y.Base.create('helloView', Y.View, [], { render: function () { var name = this.get('name'); this.get('container').set('text', 'Hello ' + (name || 'World') + '!'); return this; } }); var app = new Y.App({ views: { hello: {type: 'HelloView'} } }); app.route('/', function (req) { this.showView('hello'); }); app.route('/:name', function (req) { this.showView('hello', {name: req.params.name}); }); app.render().navigate('/eric');

Slide 48

Slide 48 text

Hello World Y.App Hello World!
Hello eric!

Slide 49

Slide 49 text

Square ing

Slide 50

Slide 50 text

Square ing

Slide 51

Slide 51 text

Photos Near Me

Slide 52

Slide 52 text

Photos Near Me

Slide 53

Slide 53 text

Questions? Eric Ferraiuolo, YUI @ericf