learn modern web application development techniques that take your company to the future chris love...

132
Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Upload: ann-gibbs

Post on 14-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Learn Modern Web Application Development Techniques That

Take Your Company to the Future

Chris Love

@ChrisLove

Love2Dev.com

Page 2: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Who Am I

• ASP.NET MVP• ASP Insider• Internet Explorer User Agent• Author• Speaker• Tweaker, Lover of Web, JavaScript, CSS & HTML5• @ChrisLove• Love2Dev.com

Page 3: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

High Performance Single Page Web Applications

• Responsive Design• Touch• Mobile First• SPA• Extensible, Scalable Architecture• Web Build and Workflow• Goes Really Fast!

• ~395 Pages• 20 Chapters• $9.99 http://amzn.to/1a55L89

BUY NOW!

Page 4: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Slide Deck(s)

• Normal Slide Decks – http://slidesha.re/15YTrTT • Today’s Slides – In a Shared Cloud Folder (check e-mail)

Page 5: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Source Code

• Source Code• Book Source Code (Movies)

• http://GitHub.com/docluv/movies• Going to use this for some Layout, Responsive Design and Touch

Demos

• New Application (Furniture Store)• https://github.com/docluv/fastfurniture• This is the reference application for SPA Techniques

Page 6: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

What Does A Modern Web App Look Like?

What is Changing the Definition of the Web?

What Does the Developer Experience Look Like?

Page 7: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Defining the Modern Web Application

?

Page 8: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Its Not This

Page 9: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com
Page 10: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Its Not This

326 Http Requests 23 Style Sheets 80kb 84 Images 587kb 101 External Scripts 806kb229 Primed Http Requests76 seconds to fully loadMultiple Unminimized ResourcesSpeed Index 594912+MB of ContentMultiple 404sMostly Uncached Content

Page 11: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

The Web Is Obese100 Files Requests – 2.2MB

22 JavaScript Files - 354KB

7.4 CSS Files – 71KB

54 Images – 1.4MB

2.9 Fonts – 111kb

39 TCP Connections

18 Domains

48% Cacheable http://httpArchive.org

Page 12: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Performance

• Multiple Studies Show Correlation Between Conversions &

Speed

• 57% Will Abandon a Slow Site After 3 Seconds

• We Have to Concentrate 50% Harder For Slow Sites

• 78% Have Felt Stress or Anger With Slow Sites

• 44% Say Slow Sites Make Them Anxious

• 4% Have Thrown Their Phone

Page 14: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Matt Cutts

"Also take a step back for a minute and consider the intent of this change: a faster web is great for everyone, but especially for users. Lots of websites have demonstrated that speeding up the user experience results in more usage. So speeding up your website isn’t just something that can affect your search rankings–it’s a fantastic idea for your users.“

http://bit.ly/SPPB4k

Page 15: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Time is Money

• Faster Sites Have Higher Conversion Rates

• WalMart - http://bit.ly/S1fHSZ• Google – http://bit.ly/WajJbB• Amazon – http://bit.ly/S3UoAj• ShopZilla - http://bit.ly/RIQMDM

Page 16: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

WalMart

Folks at Walmart knew their pages were slow. As a for instance, initial measurement showed that an item page took about 24 seconds to load for the slowest 5% of users. Why? The usual culprits: too many page elements, slow third-party scripts, multiple hosts (25% of page content is served by partners, affiliates, and Marketplace), and various best practice no-nos

http://bit.ly/WajJbB

Page 17: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Google’s ½ Second

Half a second delay caused a 20% drop in traffic. Half a second delay killed user satisfaction.The lesson, Marissa said, is that speed matters. People do not like to wait. Do not make them.

http://bit.ly/TPPhUp

Page 18: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

http://bit.ly/16zFCXL

Page 19: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Performance

• Performance Matters• It Must Be a 1st Class Feature in Any Application• Not an Afterthought Right Before Deployment• 80% of Performance Is In the Client, Not the Server• Cellular Networks Make Page Load Even Tougher• 500ms Inherent Delay• Bandwidth Constraints

Page 20: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Modern Web Applications MUST Load Fast and Respond Fast

Page 21: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Mobile or Device Fragmentation

Page 22: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Mobile Browsers

Aggressively Purge Cache

Weaker Processors

Less Memory

Page 23: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Cellular Connections

Slower

More Expensive

Unreliable

Page 24: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Touch

Page 25: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Web APIs

Page 26: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

HTML5 CSS3 JavaScript

Page 27: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

The Modern Web Hour Glass

HTML5JavaScriptCSS3

ASP.NET.IIS

DB – SQL Server/NoSQL

Page 28: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

 (API + HTML5 + CSS3 + JavaScript +

Standards Compliant Browser) *

(Touch + Mobility + Performance)

=== Great Single Page Application

Page 29: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Let’s Code

Page 30: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Introduction to Fluid Layouts

•Morph to Fill The ViewPort Space•Rely on CSS•Absolute Positioning

Page 31: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com
Page 32: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

DOCTYPE

Replace This:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

With This:

<!DOCTYPE html>

<html>

Page 33: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

DOCTYPE

"DOCTYPEs are required for legacy reasons. When omitted, browsers tend to use a different rendering mode that is incompatible with some specifications. Including the DOCTYPE in a document ensures that the browser makes a best-effort attempt at following the relevant specifications." http://www.w3.org/TR/html5/syntax.html#the-doctype

Page 34: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Absolute Positioning

.site-header {    position: absolute;    top: 0;    right: 0;    left: 0;    height: 80px;}

Page 35: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Let’s Code

Page 36: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Responsive Web Design

• Introduced by Ethan Marcotte 2010 - bit.ly/178an9e• Web Design Approach To Create An Optimal Viewing

Experience Across All Browser ViewPorts• Fluid Layouts• Media Queries• Minimal if any JavaScript Required

Page 37: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

“this unspoken agreement to pretend that we had a certain size. And that size changed over the years. For a while, we all sort of tacitly agreed that 640 by 480 was the right size, and then later than changed to 800:600, and 1024; we seem to have settled on this 960 pixel as being this like, default. It’s still unknown. We still don’t know the size of the browser; it’s just like this consensual hallucination that we’ve all agreed to participate in: “Let’s assume the browser has a browser width of at least 960 pixels.”

Jeremy Keith

bit.ly/1bhH6rw

Responsive Design

Page 38: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

“The emergence of ideas like “responsive design” and “future-friendly thinking” are in part a response to the collective realization that designing products that solve one problem in one context at a time is no longer sustainable. By refocusing our process on systems that are explicitly designed to adapt to a changing environment, we have an opportunity to develop durable, long-lasting designs that renew their usefulness and value over time.”

Wilson Miner

bit.ly/1fbq5lB

Responsive Design

Page 39: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

“Any attempt to draw a line around a particular device class has as much permanence as a literal line in the sand. Pause for a moment and the line blurs. Look away and it will be gone. Let’s take the absolute best case scenario. You’re building a web app for internal users for whom you get to specify what computer is purchased and used. You can specify the browser, the monitor size, keyboard, etc.”

Jason Grigsby

bit.ly/KzJH9G

Responsive Design

Page 40: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

“How long do you think that hardware will be able to be found? Three years from now when a computer dies and has to be replaced, what are the chances that the new monitor will be a touchscreen?By making a decision to design solely for a “desktop UI”, you are creating technical debt and limiting the longevity of the app you’re building. You’re designing to a collective hallucination. You don’t have to have a crystal ball to see where things are headed.And once you start accepting the reality that the lines inside form factors are as blurry as the lines between them, then responsiveness becomes a necessity.”

Jason Grigsby

bit.ly/KzJH9G

Responsive Design

Page 41: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com
Page 42: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com
Page 43: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com
Page 44: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Mobile First

• Determine The Most Important Information• Expand From There• Start Responsive Design Mobile First

Page 45: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Responsive Layout

Page 46: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Responsive Layout

Page 47: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Responsive Layout

Page 48: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Media Queries

@media (min-width:600px) {/* Rules Here */}

@media (min-width:800px) {/* Rules Here */}

Page 49: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Responsive Design Best Practices•Start Small Screen First•Forces Most Important Data First•Easier to Adjust CSS Rules

•Let Data Drive Media Queries First•Its Ok to Use Some JavaScript•But Not Required

Page 50: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Responsive Images

Page 51: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Responsive Images

• Img srcset

• PICTURE ELEMENT• Good for Art Direction• Media Type

• Jason Grigsby Series• http://blog.cloudfour.com/responsive-images-part-10-conclusio

n/

Page 53: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

IMG srcset

<img class="product-grid-photo" alt="sun" src="https://az763773.vo.msecnd.net/display/sun.jpg" srcset="https://az763773.vo.msecnd.net/thumb/sun.jpg 116w, https://az763773.vo.msecnd.net/mobile/sun.jpg 300w, https://az763773.vo.msecnd.net/display/sun.jpg 400w, https://az763773.vo.msecnd.net/originals/sun.jpg 1000w">

Page 54: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

PICTURE Element

Page 55: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Let’s Code

Page 56: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Touch Your Application

Page 57: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Touch Your Application

• Content Must Be Touchable• Account for Fat Fingers• Support APIs• Mouse• Touch (Apple)• Pointer (MSFT & W3C)

Page 58: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Touch Your Application

Page 59: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Touch Your Application

• The Average Human Finger is 11mm in Diameter• Fingers Range from

8mm -19mm• Baby to Large Man

Page 60: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Touch Your Application

• Touch Points Need Margin• Or Separation From

Neighbors

Page 61: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Touch Gestures

• Pan• Pinch/Zoom• Swipe• Tap• Tap + Hold• Rotate

Page 62: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Touch-action

• CSS Property to Help Determine How Touch is Handled• Auto• None• Pan-x• Pan-y

• Can disable Auto-zoom• Enable Scrolling

Page 63: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Scrolling Content

overflow: scroll;-webkit-overflow-scrolling: touch;-ms-overflow-style: -ms-autohiding-scrollbar;-ms-scroll-chaining: none;-ms-scroll-translation: vertical-to-horizontal;

Page 64: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

DeepTissue

• Abstracts Touch & Mouse APIs• Abstracts Input Modality Gestures• http://deeptissuejs.com

Page 65: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com
Page 66: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

INPUT TYPE=XXXX

• New Input Types Drive On-Screen Keyboards• Drives Native Validation• Tel, email, url, number, etc

Page 67: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Let’s Code

Page 68: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

The Server-Side Story

• Provide Markup, CSS, JavaScript, Images• API End Points• Possible Legacy URL Redirects• Deal with Search Engine Spiders and Legacy Browsers

Page 69: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

The Modern Web Hour Glass

HTML5JavaScriptCSS3

ASP.NET.IIS

DB – SQL Server/NoSQL

Page 70: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

SPAHelper Library

• Extends ASP.NET MVC• Custom SPAWebViewPage• SPAModel• SPAHelper• http://bit.ly/1dUYLGJ

Page 71: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

SPAWebViewPage

• Must Use it as Base for MVC View• Extends MVC’s WebViewPage• SPARenderPage

• Causes only Changed Content to be Sent to Client• Works in Concert with Backpack to Cache Markup in

localStorage

Page 72: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

SPAWebViewPage

• Must Configure View web.config file:

• <pages pageBaseType="SPAHelper.SPAWebViewPage">

Page 73: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

SPAWebViewPage

@if (!Html.HasEscapeFragment()) {

@SPARenderPage("views/home-view.cshtml") @SPARenderPage("views/movies-view.cshtml") @SPARenderPage("views/movie-view.cshtml")

… @SPARenderPage("views/notfound-view.cshtml") @SPARenderPage("templates/_templates.cshtml")

}

Page 74: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

SPAModel

• The SPAModel provides a base for an ASP.NET MVC single page application model• The model has properties for the application's Title and

Description• The SetRoute function parses a SPA route to isolate the

primary root

Page 75: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

SPAHelper

• The SPAHelper class is a collection of static and static ASP.NET MVC HTML Helper extension functions• SPALink• LastUpdated• HasEscapeFragment• HasForceReload

Page 76: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

_escape_fragment_

• Google’s Specification for AJAX Applications• http://bit.ly/117sTgL• Allows Routes to be Sent to Server Via QueryString• Server Sends Google Fully Rendered Markup• Good Core Site Solution• Legacy Browser Version• Andy Hume of the Guardian - http

://vimeo.com/channels/smashingconf

Page 77: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Cutting The Mustard

• First Defined By Dean Hume of the Guardian

• http://vimeo.com/channels/smashingconf

• A Progressive Enhancement Approach to Supporting Legacy Browsers

Page 78: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Cutting The Mustard

• Feature Detection• Do Not Code to

Legacy Browsers• DO NOT USE Polyfils• Also Helps With SEO• Google’s Specification

for AJAX Applications• http://bit.ly/117sTgL

Page 79: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Cutting The Mustard

• Not Needed• No Legacy Browser

Support• No Concern for

SEO• Ex. Line of

Business App

Page 80: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Cutting The Mustard

• Feature Detect to Determine Browser Capabilities• Never Browser Sniff

if (!('querySelector' in document) //at least IE8 || !('localStorage' in window) //at least IE8 || !('addEventListener' in window) //at least IE8 || !('matchMedia' in window)) {//at least IE10

} else {

}

Page 81: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Static HTML

• Eliminates The Server-Side Component(s)• Rely on the API to serve the data• Assumptions• No Obsolete Browsers (but we can deal with this scenario)• Search Engine Spiders will crawl dynamic content• No Need for SEO• API based authentication

• Works on any web server, even cloud storage

Page 82: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

makeHTML

• Node Module to Generate Index.html and Deferred.html• Grunt plugin (a Gulp plugin planned)

• Composes the Application Markup Once• Replaces the ASP.NET/PHP/Express/Ruby functionality

Page 83: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

makeHTML

makeHTML: { debug: {...}, production: { options: { "scripts": ["js/Fast-Furniture.app.min.js"], "styles": ["css/site.min.css"], "criticalCSS": "views/criticalcssmin.html", "indexSrc": "views/static.html", "src": [ "Views/Home/layouts/*.html", "Views/Home/views/*.html", "Views/Home/templates/*.html" ], "dest": "index.html" } }

Page 84: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Let’s Code

Page 85: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

The Client-Side Story

• Things You Used to Do On the Server Now Live In the Client• Routing• Rendering• Data Caching

• Need to be Conscience of How Browsers Work• Critical Rendering Path• Memory Management

• Leverage HTML5 Features• Storage• Animations

Page 86: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Critical Rendering Path

REQUEST

HTML

CSS

DOM

CSSOM

JAVASCRIPT RENDER TREELAYOUT/

PAINT

Page 87: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Press # For More

• Routes Are Not Sent to Server

• No Request/Response Intiated

• Must Respond to Route in the Client

• #! Is the Defacto Standard

Page 88: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Press # For More

window.addEventListener("hashchange", function (e) {

//swap the View Here

});

Page 89: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

What About These Guys?

•Angular•Ember•Backbone•Durandal•React

Page 90: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Cant Use Fast Food Frameworks

Page 91: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Cant Use Fast Food Frameworks

Page 92: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Common Problems

•Too Large•Try to be everything to everybody

•Memory Leaks•Many Brittle Practices•Routing•Virtualize Native Functionality

Page 93: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com
Page 94: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Dump jQuery & What it means

• Faster Load Times

• Master DOM APIs

• Alternatives

• Create DollarBill

• Learn to be Modular

• And Yes This Was

Painful

• For about 2 weeks

• But Was A Great

Experience

Page 95: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Fast Food Frameworks Are Bad

Full of Fat

Loaded With Preservatives

Syntactic Sugar

Page 96: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

MicroJS Libraries

Small

Promote Modular Architecture

Single Focus

Page 97: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

The Love2SPA Way

• SPAjs• Backpack/Mud Bath *• DollarBill**• Caching AJAX Layer• HTML Template Engine• Deeptissue• Toolbar, Panorama, Other Small UI Libraries

* Under Development ** jQuery Compatible

Page 98: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

The Love2SPA Way – Typical Stats

• 35-80kb minified, not gzipped JavaScript• 20-35kb minified, not gzipped CSS• 5-35kb minified, not gzipped HTML• 3 Core Http Requests•< 1 second Load Time

Page 99: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com
Page 100: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

The Love2SPA Way

• Extensible• Scalable• Maintainable• Testable• Deployable• Have Tangible

ROI

Page 101: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

The 1st Time a User Visits They ‘Install’ the Application

Application Loading Process

Page 102: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

•The Initial Request•Contains Critical Path Assets•Master Layout HTML + CSS Inline• Initial Possible Views• Initial View’s CSS• Core Application JavaScript + Initial View’s Controllers

Application Loading Process

Page 103: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

•Deferred Request(s)•Contains Additional View HTML, CSS and JavaScript

Application Loading Process

Page 104: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

API

We b A p p l i c a t i o n

A J A X

S PA

C A C H E

D ATA A P P

V I E WV I E WV I E WV I E WV I E WC o n t r o l l e r

V i e w E n g i n e

Te m p l a t e E n g i n e

Page 105: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

SPAjs

• Responsible for Routing

• View Switching

• Executes Animations

• Relies on Animate.css - http://bit.ly/1hayo4s

• Executing View Onload and Unload Functions

Page 106: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Markup Management

•Keep the DOM Lean•Leverage Browser Storage to Persist Markup• http://bit.ly/H2qhZ2

Page 107: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

View Engine – Cache Markup

•Parses Markup For Views &

Templates

•Stores All Markup Related Concerns

in Storage

•Retrieves View Markup On Demand

•Abstracts Templating or Binding

Library

Page 108: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

View Engine – Lazy Loading

•Reduces Initial Load•Enables 14kb Goal•View Engine Still Parses Markup & Caches•Also caches and injects CSS & Script References

Page 109: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

AjaxPrefilter

• Caches Data in localStorage with a TTL

• 1st Implement by Paul Irish

• http://bit.ly/117p7E9

• Can be Used with Any AJAX Implementation

• Eliminates Unnecessary HTTP Requests

Page 110: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Data Management

• Eliminate Redundant HTTP Requests• The Fastest HTTP Request is the one you don’t make• Intercept AJAX GET Requests• Determine if Data is Cached

Page 111: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Data Management

Data Requested

Is In Cache?

Yes

No

Return Data

Make AJAX Request

Cache DataReturn Data

Page 112: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Markup Management

•Keep the DOM Lean•Leverage Browser Storage to Persist Markup• http://bit.ly/H2qhZ2

Page 113: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

View Engine – Cache Markup

•Parses Markup For Views &

Templates

•Stores All Markup Related Concerns

in Storage

•Retrieves View Markup On Demand

•Abstracts Templating or Binding

Library

Page 114: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

View Engine – Lazy Loading

•Reduces Initial Load•Enables 14kb Goal•View Engine Still Parses Markup & Caches•Also caches and injects CSS & Script References

Page 115: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

JavaScript Templating

• Merges JavaScript Objects with Markup

• Many Libraries

• Micro-Templating

• MUSTACHE

• Rivets/MVVM

• Generated Markup Appended to DOM

Page 116: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

JavaScript Templating

<script id="MoviePosterGridTemplate" type="text/x-mustache-template"> {{#movies}} <div class="movie-target"> <a href="#!movie/{{id}}/{{title}}"> <img alt="{{title}}" src="{{poster}}" class="movie-grid-poster"> <figcaption class="demo-photo-caption">{{title}}</figcaption> </a> </div> {{/movies}}</script>

Page 117: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Let’s Code

Page 118: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Create Modular, Extensible JavaScript Application• Functions 1st Class in JavaScript• Functions are Objects• var foo = {};• All Objects have a Prototype• new Keyword creates a new Object• Many popular Patterns

Page 119: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Extensible

Core

Module

Module

Module

Page 120: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Think Like jQuery

• The jQuery Module Pattern is Familiar• Not Hard to Implement• Allows for Extensibility

Page 121: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

A SPA Application Module

App

View

View

View

Page 122: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Let’s Code

Page 123: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Building Web Applications

• Just Like C# Applications• Release• Debug

• The Web Needs a Compiler• 2 Great Options• Grunt• Gulp

Page 124: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Building Web Applications

• Grunt & Gulp Are Node Modules• http://gruntjs.com• http://gulpjs.com• Both have great eco-systems

• Add To package.json• Run npm install• Create gruntfile.js• Grunt.cmd

Page 125: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Let’s Code

Page 126: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Going Offline

• Leverage the AppCache• Create a Manifest File• Don’t Let it be a Handicap• http://bit.ly/117q27A

• Makes Sure Your App Will Work Without Connectivity• Good for Caching Images and Resources• Makes the Browser look Local Before Going to the Server

Page 127: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Developing with AppCache is a PITA

@{if (HttpContext.Current.IsDebuggingEnabled){    @:<html lang="en">    }else{    @:<html lang="en" manifest="app.cache">    }}

Page 128: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Manifest File

• CACHE• lists all resources that should be downloaded for offline use

•NETWORK•  identifies any URLs that require the device be connected to

the network

• FALLBACK• lists replacement URLs for network URLs to be used when the

device is offline

Page 129: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

How AppCache Works

•When the browser reads the manifest file it downloads the specified resources locally• Those resources are referred too instead of making a request to the server• Resources are refreshed if the manifest file has been updated

Page 130: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Let’s Code

Page 131: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

High Performance Single Page Web Applications

• Responsive Design• Touch• Mobile First• SPA• Extensible, Scalable Architecture• Web Build and Workflow• Goes Really Fast!

• ~395 Pages• 20 Chapters• $9.99 http://amzn.to/1a55L89

BUY NOW!

Page 132: Learn Modern Web Application Development Techniques That Take Your Company to the Future Chris Love @ChrisLove Love2Dev.com

Questions