javascript wash - story of ui development

42
JavaScript Wash Story of a UI Development M A Hossain Tonu http://mahtonu.wordpress.com Tweets @mahtonu Improsys, Inc

Upload: m-a-hossain-tonu

Post on 20-Nov-2014

3.077 views

Category:

Technology


1 download

DESCRIPTION

JavaScript Wash - Story of UI Development

TRANSCRIPT

Page 1: JavaScript Wash - Story of UI Development

JavaScript WashStory of a UI Development

M A Hossain Tonuhttp://mahtonu.wordpress.com

Tweets @mahtonuImprosys, Inc

Page 2: JavaScript Wash - Story of UI Development

Objective

PhpXperts Seminar 2010

Page 3: JavaScript Wash - Story of UI Development

Contents

• JS in Mobile Application Development

• Interactive UI samples

• Open Source JS Libraries

• The High-Performance JS Mantra

• Tools

PhpXperts Seminar 2010

Page 4: JavaScript Wash - Story of UI Development

Some Common Issues

• JavaScript != Java

• Client/Server Side JS = YES

• Non-Web-related apps = YES

• OOP Support = YES

• Multi-threading PhpXperts Seminar 2010

Page 5: JavaScript Wash - Story of UI Development

Only for web browsers? No

Rhino - Open source JS engine for Java.

Aptana Jaxer - Server side JS

Node.js – Client- Server JS

PhpXperts Seminar 2010

Page 6: JavaScript Wash - Story of UI Development

Runs within a host environment

Web browser

Adobe Acrobat

Photoshop

Windows Scripting Host

Yahoo! Widget Engine

and more...

PhpXperts Seminar 2010

Page 7: JavaScript Wash - Story of UI Development

JS in Mobile Application Development

Titanium RhoMobile PhoneGap

PhpXperts Seminar 2010

Devices =

Dev. Platform =

Page 8: JavaScript Wash - Story of UI Development

Interactive UI using JavaScript

PhpXperts Seminar 2010

Page 9: JavaScript Wash - Story of UI Development

Interactive UI using JavaScript

PhpXperts Seminar 2010

Page 10: JavaScript Wash - Story of UI Development

Interactive UI using JavaScript

PhpXperts Seminar 2010

Page 11: JavaScript Wash - Story of UI Development

Interactive UI using JavaScript

PhpXperts Seminar 2010

Page 12: JavaScript Wash - Story of UI Development

Interactive UI using JavaScript

PhpXperts Seminar 2010

Page 13: JavaScript Wash - Story of UI Development

PhpXperts Seminar 2010

= Yes

Page 14: JavaScript Wash - Story of UI Development

All you need

• JavaScript Libraries

• High Performance JavaScript Mantra

PhpXperts Seminar 2010

Page 15: JavaScript Wash - Story of UI Development

Open Source JS Libraries

• General Purpose:– Prototype – jQuery – Yahoo! UI – Dojo – Ext JS

• Task Specific:– Script.aculo.us (Effects)

– moo.fx (Effects)

– $fx() (Animation)

– Rapheal (Vector Graphics)

– Glimmer (Interaction)

PhpXperts Seminar 2010

Page 16: JavaScript Wash - Story of UI Development

Why JS Libraries?

• High Performance• Development -> faster• cross-browser

PhpXperts Seminar 2010

Page 17: JavaScript Wash - Story of UI Development

High-Performance JavaScript Matters

• Fast apps =

• Slow apps =

• AJAX = responsiveness!!

• User experience = WOW!

PhpXperts Seminar 2010

Page 18: JavaScript Wash - Story of UI Development

The High-Performance JS Mantra

• Be Lazy

• Be Responsive

• Be Vigilant

PhpXperts Seminar 2010

Page 19: JavaScript Wash - Story of UI Development

The High-Performance JS Mantra

• Be Lazy : Nothing is faster than doing nothing

• Be Responsive

• Be Vigilant

PhpXperts Seminar 2010

Page 20: JavaScript Wash - Story of UI Development

Be Lazy: Nothing is faster than doing nothing

• Write less code

• Frequent code releases Frequently re-download

• More code = more to download, execute, maintain, etc

PhpXperts Seminar 2010

Page 21: JavaScript Wash - Story of UI Development

Be Lazy: Nothing is faster than doing nothing

• Before:

• After:

PhpXperts Seminar 2010

/*** The dom module provides helper methods for* manipulating Dom elements.* @module dom**/

(function() {var Y = YAHOO.util, // internal shorthand

getStyle, // for load time browser branchingsetStyle, // dittopropertyCache = {}, // for faster hyphen convertsreClassNameCache = {}, // cache regexes for classNamedocument = window.document; // cache for faster lookups

YAHOO.env._id_counter = YAHOO.env._id_counter || 0;

(function(){varB=YAHOO.util,K,I,J={},F={},M=window.document;YAHOO.env._id_counter=YAHOO.env._id_counter||0;

MINIFY = Good

Page 22: JavaScript Wash - Story of UI Development

Be Lazy: Nothing is faster than doing nothing

• Load JS on-demand

• Less HTTP RequestsBefore:

After:

PhpXperts Seminar 2010

<script src="all.js“ type="text/javascript“></script>

<script src="jquery.js"></script><script src="jquery.twitter.js"></script><script src="jquery.cookie.js"></script><script src="myapp.js"></script>

Page 23: JavaScript Wash - Story of UI Development

Be Lazy: Nothing is faster than doing nothing

• Draw UI as late as possible

Draw less DOM = faster

Pre-draw hidden UI = No

Cache = Yes

Hidden UI updating = No

PhpXperts Seminar 2010

Page 24: JavaScript Wash - Story of UI Development

PhpXperts Seminar 2010

Never pre-draw hidden UI

Page 25: JavaScript Wash - Story of UI Development

PhpXperts Seminar 2010

Never pre-draw hidden UI

Page 26: JavaScript Wash - Story of UI Development

PhpXperts Seminar 2010

Never pre-draw hidden UI

Page 27: JavaScript Wash - Story of UI Development

PhpXperts Seminar 2010

Never pre-draw hidden UI

Page 28: JavaScript Wash - Story of UI Development

PhpXperts Seminar 2010

Never pre-draw hidden UI

Page 29: JavaScript Wash - Story of UI Development

The High-Performance JS Mantra

• Be Lazy

• Be Responsive: Jump when the user

says jump

• Be Vigilant

PhpXperts Seminar 2010

Page 30: JavaScript Wash - Story of UI Development

Be Responsive: Jump when the user says

jump

• Minimize initial load time

CSS at topJS at bottomUI placeholder > “loading”Load in stages

• Yield early and often

do min. work, use setTimeout() to yield

PhpXperts Seminar 2010

Page 31: JavaScript Wash - Story of UI Development

Be Responsive: Jump when the user says

jump

PhpXperts Seminar 2010

Load your app in stages

Page 32: JavaScript Wash - Story of UI Development

Be Responsive: Jump when the user says

jump

PhpXperts Seminar 2010

Load your app in stages

Page 33: JavaScript Wash - Story of UI Development

Be Responsive: Jump when the user says

jump

PhpXperts Seminar 2010

Load your app in stages

Page 34: JavaScript Wash - Story of UI Development

Be Responsive: Jump when the user says

jump

PhpXperts Seminar 2010

Load your app in stages

Page 35: JavaScript Wash - Story of UI Development

Be Responsive: Jump when the user says

jump

PhpXperts Seminar 2010

Load your app in stages

Page 36: JavaScript Wash - Story of UI Development

Be Responsive: Jump when the user says

jump

PhpXperts Seminar 2010

Load your app in stages

Page 37: JavaScript Wash - Story of UI Development

Be Responsive: Jump when the user says

jump

PhpXperts Seminar 2010

Load your app in stages

Page 38: JavaScript Wash - Story of UI Development

The High-Performance JS Mantra

• Be Lazy

• Be Responsive

• Be Vigilant: Only you can prevent slow web

apps

PhpXperts Seminar 2010

Page 39: JavaScript Wash - Story of UI Development

Be Vigilant: Only you can prevent slow web

apps

• Profile like crazyUse firebug’s profiler (Joe Hewitt, you rule! )Use timestamp diffs and alerts

PhpXperts Seminar 2010

Page 40: JavaScript Wash - Story of UI Development

Tools

PhpXperts Seminar 2010

Page 41: JavaScript Wash - Story of UI Development

Questions

PhpXperts Seminar 2010

Page 42: JavaScript Wash - Story of UI Development

References

JavaScript: The World's Most Misunderstood Programming Language

Private Members in JavaScript

Books:

JavaScript: The Good Part by Douglus Crockford

JavaScript: The Definitive Guide (5th Edition) by David Flanagan

jQuery Cheat sheet

Server side JS

PhpXperts Seminar 2010