SlideShare a Scribd company logo
1 of 61
Basics of Rich Internet Applications
Doing things right for the Web 2.0 and beyond




                                        Subramanyan Murali
                           Frontend Engineer, YDN Evangelist
Overview
•    What is Rich Internet Applications ?
•    Benefits
•    Do things right from the start
•    Separation of Concern
     –  HTML for Markup
           •  Semantic Markup
     –  CSS for Presentation
           •  Class hierarchies
           •  Cascading
     –  Javascript for Behavior
           •  JS libraries




Technical Presentation            2
Overview …
     –  Ajax for Data interchange
     –  Using Libraries to add for Effects
     –  Choose your data Interchange
•  Progressive Enhancement




Technical Presentation            3
Rich internet Applications




 4
Technical Presentation
RIA
•  Users are dissatisfied with the capabilities and
   performance of simple HTML-based Web applications
•  Need for desktop type interactions
•  Bringing Interactivity & Intuitiveness Into Web
   Applications
•  Adds complexity to design, develop, deploy and debug
Benefits
•  Features that WOW the users
•  Lot of processing can be off-loaded to the client
•  Adoption spreads rapidly and dramatically
•  Improved responsiveness
•  Platform independence
•  Businesses have more reach to their offerings through
   Rich web applications.
•  Deployments costs are minimal




Technical Presentation      6
Web development over the
               years
  End user expects more from current technologies




 7
Technical Presentation
Perspective
•  Over the years, there have not been too many radical
   developments in Web technologies
•  User demand and expectations is ever changing
•  The browser is a very hostile development environment
   –  The web browser was never designed for rich applications
   –  Multiple browsers just adds to complexity
•  Web developer needs to a unique mix of engineers and
   Designers
Perspective …
•  Web development standards are not friendly to rich
   applications development
•  But following standards will ensure stability and
   standard proofing apps




Technical Presentation      9
Concepts
      Tricks / approaches / standards for better web
                       development




 10
Technical Presentation
Consider
<link rel=quot;stylesheetquot; type=quot;text/cssquot; href=“fonts-min.cssquot; />
<body>
 <div style=‘border:1px solid;’>
  <a href=‘#’ onClick=“doSomething(this);” id=‘something’>Click</a>
  <form name=‘sample’ style=‘font-size:10px;’ >
   <input type=‘text’ name=‘search’ value=‘type text’ onKeyPress=‘check();’ />
   <input type=‘submit’ onclick=“validate(this.form);” />
  </form>
 </div>
</body>
<script type=‘text/javascript’>
  function doSomething(o) { … }
  function validate(f) { … }
  function check() { … }
</script>
Separation of concern
<link rel=quot;stylesheetquot; type=quot;text/cssquot; href=“fonts-min.cssquot; />
<body>
 <div style=‘border:1px solid;’>
  <a href=‘#’ onClick=“doSomething(this);” id=‘something’>Click</a>
  <form name=‘sample’ style=‘font-size:10px;’ >
   <input type=‘text’ name=‘search’ value=‘type text’ onKeyPress=‘check();’ />
   <input type=‘submit’ onclick=“validate(this.form);” />
  </form>
 </div>
</body>
<script type=‘text/javascript’>
  function doSomething(o) { … }
  function validate(f) { … }
  function check() { … }
</script>


Technical Presentation                12
Separation of concern …
<link rel=quot;stylesheetquot; type=quot;text/cssquot; href=“fonts-min.cssquot; />
<body>
                         Ajax 
 <div style=‘border:1px solid;’>            DHTML Effects 
  <a href=‘#’ onClick=“doSomething(this);” id=‘something’>Click</a>
  <form name=‘sample’ style=‘font-size:10px;’ >
                         CSS               Javascript 
   <input type=‘text’ name=‘search’ value=‘type text’ onKeyPress=‘check();’ />
   <input type=‘submit’ onclick=“validate(this.form);” />
  </form>
 </div>
</body>
                                   HTML 
<script type=‘text/javascript’>
  function doSomething(o) { … } Server Side 
  function validate(f) { … }
  function check() { … }
</script>                        Data Store 

Technical Presentation                13
Markup
•  Getting Makrup right is very important
•  “HTML Provides a means to describe the structure of
   text-based information in a document” – W3C
•  It’s a good practice to follow strict.dtd
           <!DOCTYPE HTML PUBLIC quot;-//W3C//DTD HTML 4.01//EN”
             quot;http://www.w3.org/TR/html4/strict.dtdquot;>




Technical Presentation            14
Markup …
•  Just write markup for what you want at that moment
     –  Never code markup for the future
•  Adding many divs and classes and ids to everything
   does not make a good markup
•  Representing content and establishing structure is a
   good practice
     –  Split into Headers, Body, footers, navigation etc
     –  Use Ids and classes to get that distinction




Technical Presentation            15
Markup …
<!-- Splitting into Sections -->
     <div id='container'>
      <div class='header'>
       <div class='headertitle'></div>
       <div class='closelink'>
        <img src='close.gif' alt='Close link'>
       </div>
      </div>
      <div class='body'>...</div>
      <div class='footer'></div>
     </div>




Technical Presentation                   16
Markup …
•  Adding too many DIVs can be termed ‘Divitees’
•  Keep things simple, do not pre estimate number of
   classes, ids and markup
•  Splitting based on semantic meaning of the markup
   elements is better
     –  Semantic = Meaning
•  Add 'presentation identifiers' for CSS as needed
     –  Identifiers can be as concise as possible




Technical Presentation           17
Markup …
<!-- Better way to write -->
     <div id='container'>
      <h2>Header title <img src='close.gif' alt='Close link'></h2>
      <div class='bd'>...</div>
      <div class='ft'></div>
     </div>


•  This is the same representation of data, but is more
   semantic




Technical Presentation                  18
Markup …
•  All elements generate a box
     –  Block-level elements (div, paragraph, list) are formatted as
        a principal box, and start on a new line
     –  Inline elements (span, img, strong) appear within context,
        with no new line
•  Inline boxes should not contain block boxes




Technical Presentation            19
Markup …

                               padding
                                                  margin-top

                     Header Text




                           This is Body text. This is Body text.
                           This is Body text. This is Body text.




                     Footer Text

                          margin-bottom
                                                  padding

Technical Presentation                       20
Cascading Style Sheets
•  Styles specified in CSS cascade from parent
•  When a child chooses to over ride a CSS attribute, the
   last given CSS attribute takes precedence
•  CSS attributes can specifically be asked to quot;inheritquot;
   value from ancestor
•  If the parent element has many child elements, the class
   selector for the parent can be used to define styles for
   its children




Technical Presentation       21
CSS …
  <div class='test'>
  <p>This is test para <span>and test span</></p>
  <h3>This is test heading </h3>
  <a href='http://yahoo.com'>Yahoo! Link </a>
  </div>

  .test p { /*styles for para tag*/ }
  .test p span { /*styles for span tag inside para*/ }




Technical Presentation                   22
CSS …
•  Inline boxes cannot have dimensions and some other
   properties declared
•  Floating or absolutely positioning any element makes it
   a block-level element
•  CSS has to be separated out
     –  Presentation styles
           •  Colors, font sizes, font families
     –  Positional Styles
           •  Floats, Positions, Margins, Paddings




Technical Presentation                   23
CSS …
•  Normal Flow
     –  Includes normal positioning and relative positioning for
        block and inline boxes
•  Float Model
     –  In the float model, a box is first laid out according to the
        normal flow, then taken out of the flow and shifted to the
        left or right as far as possible. Content may flow along the
        side of a float
•  Absolute Positioning
     –  In the absolute positioning model, a box is removed from
        the normal flow entirely and assigned a position with
        respect to a containing block. This has no impact on later
        siblings.


Technical Presentation            24
CSS …
•  Specificity : It is a process used to determine which
   rules take precedence in CSS when several rules could
   be applied to the same element in markup
•  Specificity calculations aid
     –    Every id selector (#whatever) = value of 100
     –    Every class selector (.whatever) = value of 10
     –    Every HTML selector (whatever) = value of 1
     –    Add them all up = specificity value
•  div p.tree > div p
•  body #content .alternative p > div p.tree
•  Specificity is irrespective of order



Technical Presentation              25
CSS …
•  Do not use too many CSS hacks
     –  Most commonly used hacks will be for the Box model
        differences
     –  *css-attribute will make the class visible only to IE
        browsers
•  If you are forced to have many CSS hacks, group all of
   them together
     –  Using specificity rules, you can override specific styles
•  Float model hacks will be the more commonly used




Technical Presentation            26
CSS …
•  CSS design can almost never be got right in the first go
     –  Need to constantly update the CSS
•  Hence, never over design your styles
     –  Code for what you need, trying to make it as generic as
        possible
•  With clean markup and proper CSS design, flexible Web
   2.0 layouts is possible
     –  Will reduce maintenance costs
     –  Layout changes are simple
•  With demanding Web 2.0 applications, namespacing
   CSS class names can be important



Technical Presentation           27
CSS …
•  Namespaces can be chosen based on design
     –  Section names
     –  Feature
     –  Style category


div.nav-section { }
div.nav-link { }
div.footer { }
•  Do not choose style names that explain what the class
   does
     –  Class names should explain what they are meant for



Technical Presentation          28
CSS …
•  CSS Class nesting can be a powerful aid to your design
•  When classes are nested, the styles applied will be a
   union of the the 2 classes
•  Class nesting can make the markup more readable

.section {
  padding: 2px 4px;
  color: black;
 }
.highlight {
  border: 1px solid;
}
                <div class=‘section highlight’>Test</div>


Technical Presentation             29
Javascript
•  Javascript was primarily used for client side validation
•  With the demands of Web 2.0, Javascript is the chosen
   technology for dynamic scripting on the client to create
   rich internet applications
•  Javascript is Object oriented
•  All javascript used on the page needs to be closest to
   the closing HTML tag as possible
•  Client side behaviour is programmed using Javascript




Technical Presentation       30
Javascript …
•  Use a Javascript Library where ever possible
     –  Libraries are solutions that manage various client side
        issues centrally
     –  Cross browser issues are handled by the library
•  Do not over design your javascript
     –  Start simple
     –  Choose a well known design pattern
     –  Stick to the design
•  Try to reduce the use of Global variables
     –  In JavaScript the window object is the global scope
     –  This is the highest scope in the scope chain
•  Always namespace your scripts

Technical Presentation           31
Javascript …
•  Simple Namespacing
function validate-text() { }
function effects_tween(o) { }
function effects_animate() { }

•  Object Namespace
var myApp = {};
myApp.globals = {};
myApp.methods = {};
myApp.methods.multiply = function(a, b) { }



Technical Presentation       32
Javascript …
•  Having a object namespace will allow for easier cleanup
   during page clean-up or garbage collection

     window.onunload = function(e) {
       myApp = null; /* All the properties are cleared */
     }

•  Namespaces also helps for better code organization
•  In the web 2.0 world, there is a lot of code mixing around
     –  Widgets may exist in other pages
     –  Namespace can ensure you have complete control over
        your code execution


Technical Presentation            33
Javascript …
     myApp.methods.generate = function ( o ) { };
     function generate = function (a, b) { };


•  YUI 2.x uses the YAHOO namespace
•  YUI 3.x uses the YUI namespace
     –  With the change from YAHOO to YUI we are guaranteed
        not to break backward compatibility. This allows you to
        use both YUI 2.x and YUI 3.x on the same page without fear
        of breaking existing code.




Technical Presentation           34
Javascript …
•  Anonymous functions are used to execute code which
   only needs to be executed once
•  In JavaScript, a function can be used wherever
   expressions can be used
•  A function can be passed as a argument in javascript
•  If you don't need to re-use the callback function (name),
   write the function definition directly
     foo ( somedata, function( ) { // callback function });




Technical Presentation             35
Javascript …
•  When a nested function has access to the scope of it’s
   parent function, it is called a closure
•  In JavaScript, if the interpreter can’t find a variable in
   it’s current scope, it’ll go up the scope chain and
   searches the parent scope until it finds the variable
     function foo(){
        var msg = quot;hello worldquot;;
        function bar(){
           alert(msg);
        };
        bar();
     };
     foo();


Technical Presentation             36
Javascript …
•  Inside the scope, the function bar() can be called many
   times, and each time, it will have access to the variable
•  Closure example
     –  http://indiahacku.in/subram/dataFetch.js




Technical Presentation           37
Javascript …
•  In DHTML, every time a quot;stylequot; gets changed for a visible
   element, there is an internal reflow happening in the
   browser. This can slow up a little bit or can cause
   unnecessary flicker
     –  Either make the element display:none and apply all styles
        ( handling height and width may require element be
        visible )
     –  Or detach the element from the parent node, do all
        manipulation, and re attach the item to the parent




Technical Presentation           38
Javascript …
•  Accessing the quot;stylequot; property of the element every
   time (in the example), we can cache the property
   accesses to gain a small performance increase:

               var d = document.getElementById(quot;containerquot;),
                   e = d.style;
               e.display = quot;quot;; // make it visible
               e.background = quot;#fffquot;;
               e.color = quot;#000quot;;
               // some more changes to d.style via e




Technical Presentation              39
Javascript …
•  Caching function pointers can give performance
   improvements
•  The global lookup for every iteration can be avoided by
   rewriting the quot;doMyDutyquot; as:

           function doMyDuty( collection ) {
             var i, n = collection.length;
             var fcn= doStuff;
             for (i = 0; i < n; i++) {
               fcn( collection[i] );
             }
           }
• 
Technical Presentation              40
Ajax
•  Ajax must be the last layer in a web application
•  Core functionality must never reply on Ajax
•  Ajax must be extensively used to enhance functionality
   which reply on data from the server
•  Since Javacsript can take up some business logic, we
   do not need to rely on server side processing
     –  Raw data can be processed on the client




Technical Presentation          41
Ajax …
•  Ajax should be used to enhance user experience, it
   should not be the only experience
•  Progressively enhance the page
     –  Introduced to subvert the traditional quot;Graceful
        Degradationquot; development method
•  Get more data as and when user requests and cache it
   on the client
•  When Application has to deal with Bandwidth issues
•  Provide a Abort operation where ever possible




Technical Presentation           42
Ajax …
•  Advantages of using Ajax
     –  Rich User Interface
           •  User can be more engaged
           •  User need not load the page everytime to get new
              information
     –  Snappier Response Time
           •  Lesser content can be loaded the first time
     –  Lower Bandwidth Usage
           •  No page reloading
           •  Only data specific to user request can be loaded
     –  Separation of content, formatting and behaviour




Technical Presentation                43
Ajax …
•  Disadvantages of using Ajax
     –  Some User Agents may not support Ajax
     –  Search Engine Optimization gets a hit if not properly
        designed
           •  Search engines crawlers may not be smart enough to
              navigate the Ajax based pages
     –  Bad Frontend development can hide the URLs of the link
        that initiate Ajax calls
     –  Accessibility of the page can be affected
           •  Problem for users that assume GET requests do not change
              the state of an application
           •  Confuses Robots, Spiders
           •  Shows Bad Design – Designer does not know the difference
              between GET & POST requests

Technical Presentation               44
Ajax …
•  Any client-side changes to the page (using DHTML) are
   not recorded in the browser's history
     –  Yahoo! Browser History Manager can help
•  Back/forward buttons do not work well with rich
   applications that use DHTML, they need to be controlled
   by the developer
•  Cross-domain requests
     –  Using a server side proxy is the most suitable solution




Technical Presentation            45
JSON
•    JavaScript Object Notation.
•    A Data Interchange Format.
•    Text-based.
•    Light-weight.
•    Easy to parse.
•    Language Independent.
•    A Subset of ECMA-262 ECMAScript Third Edition.




Technical Presentation       46
JSON …
•  Not a document format
•  Not a markup language
•  Not a general purpose serialization format
     –  It is perfectly suited for the Web and RIA




Technical Presentation            47
JSON …
•  { “key” : value, ... }
•  The “key” is a string
•  The “value” can be anything - strings, numbers, boolean,
   objects, arrays or null




Technical Presentation      48
JSON …
•    MIME type - application/json
•    Strictly UNICODE
•    Default is UTF-8
•    UTF-16 and UTF-32 are accepted




Technical Presentation      49
JSON …
•  Step 1 : XMLHttpRequest
•  Step 2 : Obtain responseText
•  Step 3 : Parse the responseText

    var responseData = eval ( ' ( ' + responseText + ' ) ' );




Technical Presentation           50
JSON …
•  Available in ECMAScript 4th Edition
     –  JSON: The Fat-Free Alternative to XML - Douglas
        Crockford - http://www.json.org/fatfree.html
•  New Methods:
     –  Object.prototype.toJSONString
     –  String.prototype.parseJSON
•  In current versions, it can be used by including
   JSON.org/json2.js (http://www.json.org/js.html)
•  Parse the responseText
     –  var responseData = JSON.parse(responseText);




Technical Presentation          51
Cross Browser Support
                         Browser differences are painful




 52
Technical Presentation
Cross Browser …
•  Browsers have differences in standards implementation
•  Browsers have Bugs
•  Developing for multiple browsers can be a daunting task
   –  Box model differences
   –  Support differences
   –  Javascript performance
•  Yahoo!s Graded Browser support details out browsers
   into 3 grades
   –  http://developer.yahoo.com/yui/articles/gbs/
Cross Browser
•  http://www.quirksmode.org/compatibility.html#t01
•  Using CSS and Javascript libraries can be really helpful
   when dealing with cross browser issues
•  Working with a strict doctype will ensure that most
   browsers work in the standards compliant mode




Technical Presentation       54
Cross Browser …
•  Browsers are not limited to browsers on the computer
•  Mobile phones have their own complexities
•  With more mobile users, need for rich web applications
   to run on their respective devices is essential




Technical Presentation      55
Progressive enhancement
                         First inspect, then provide




 56
Technical Presentation
Progressive Enhancement
“Checking if the ice can carry you before stepping on it”
   –  Christian Heilmann


•  Simply means that you test for an improvement before
   you apply it
•  System design and development methodology makes it
   possible to build in a layered fashion
•  Accessibility and Performance are accounted for right
   at the start
•  Layers should be made to be replaceable - swap the
   HTML layer with an RSS layer and CSS with XSLT
Progressive Enhancement …
•  Browser capability testing is done by Nag bars, which
   retrieve information about the browser prior to sending
   the actual page
•  Progressive enhancement may avoid you the trouble for
   maintaining different pages for different user agents
•  The Interactivity demanded by users and user
   experience is determined based on the capabilities of
   devices




Technical Presentation      58
Progressive Enhancement …
•    Build for C grade
•    Test for C grade
•    Add style and behavior for A grade
•    Test for A grade
•    Test in X Grade
•    Fix for X Grade if needed




Technical Presentation        59
Examples




 60
Technical Presentation
Thank you




 61
Technical Presentation

More Related Content

What's hot

Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
Terry Ryan
 
2012 03 27_philly_jug_rewrite_static
2012 03 27_philly_jug_rewrite_static2012 03 27_philly_jug_rewrite_static
2012 03 27_philly_jug_rewrite_static
Lincoln III
 
Ss 36932418[1]
Ss 36932418[1]Ss 36932418[1]
Ss 36932418[1]
Ya Jinda
 

What's hot (20)

Avoiding the Slog of Real-time Data Distribution
Avoiding the Slog of Real-time Data DistributionAvoiding the Slog of Real-time Data Distribution
Avoiding the Slog of Real-time Data Distribution
 
Rapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with BootstrapRapid and Responsive - UX to Prototype with Bootstrap
Rapid and Responsive - UX to Prototype with Bootstrap
 
Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3
 
Beautiful Java EE - PrettyFaces
Beautiful Java EE - PrettyFacesBeautiful Java EE - PrettyFaces
Beautiful Java EE - PrettyFaces
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
iPhone Web Applications: HTML5, CSS3 & dev tips for iPhone development
iPhone Web Applications: HTML5, CSS3 & dev tips for iPhone developmentiPhone Web Applications: HTML5, CSS3 & dev tips for iPhone development
iPhone Web Applications: HTML5, CSS3 & dev tips for iPhone development
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
Progressive Prototyping w/HTML5, CSS3 and jQuery
Progressive Prototyping w/HTML5, CSS3 and jQueryProgressive Prototyping w/HTML5, CSS3 and jQuery
Progressive Prototyping w/HTML5, CSS3 and jQuery
 
Html5 ux london
Html5 ux londonHtml5 ux london
Html5 ux london
 
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
PrettyFaces: SEO, Dynamic, Parameters, Bookmarks, Navigation for JSF / JSF2 (...
 
2012 03 27_philly_jug_rewrite_static
2012 03 27_philly_jug_rewrite_static2012 03 27_philly_jug_rewrite_static
2012 03 27_philly_jug_rewrite_static
 
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
 
ActiveDOM
ActiveDOMActiveDOM
ActiveDOM
 
Introduction to web components
Introduction to web componentsIntroduction to web components
Introduction to web components
 
Html5 & CSS overview
Html5 & CSS overviewHtml5 & CSS overview
Html5 & CSS overview
 
Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)
 
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
 
HTML5 and the web of tomorrow!
HTML5  and the  web of tomorrow!HTML5  and the  web of tomorrow!
HTML5 and the web of tomorrow!
 
Ss 36932418[1]
Ss 36932418[1]Ss 36932418[1]
Ss 36932418[1]
 

Similar to Basics of Rich Internet Applications

3 coding101 fewd_lesson3_your_first_website 20210105
3 coding101 fewd_lesson3_your_first_website 202101053 coding101 fewd_lesson3_your_first_website 20210105
3 coding101 fewd_lesson3_your_first_website 20210105
John Picasso
 
Microformats HTML to API
Microformats HTML to APIMicroformats HTML to API
Microformats HTML to API
elliando dias
 
Even faster web sites presentation 3
Even faster web sites presentation 3Even faster web sites presentation 3
Even faster web sites presentation 3
Felipe Lavín
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
MySQLConference
 
Single Page WebApp Architecture
Single Page WebApp ArchitectureSingle Page WebApp Architecture
Single Page WebApp Architecture
Morgan Cheng
 

Similar to Basics of Rich Internet Applications (20)

Standardizing the Web: A Look into the Why of Web Standards
Standardizing the Web: A Look into the Why of Web StandardsStandardizing the Web: A Look into the Why of Web Standards
Standardizing the Web: A Look into the Why of Web Standards
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
Real-World AJAX with ASP.NET
Real-World AJAX with ASP.NETReal-World AJAX with ASP.NET
Real-World AJAX with ASP.NET
 
Semantics & the Mobile Web
Semantics & the Mobile WebSemantics & the Mobile Web
Semantics & the Mobile Web
 
3 coding101 fewd_lesson3_your_first_website 20210105
3 coding101 fewd_lesson3_your_first_website 202101053 coding101 fewd_lesson3_your_first_website 20210105
3 coding101 fewd_lesson3_your_first_website 20210105
 
HTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.pptHTML Web Devlopment presentation css.ppt
HTML Web Devlopment presentation css.ppt
 
css.ppt
css.pptcss.ppt
css.ppt
 
css.ppt
css.pptcss.ppt
css.ppt
 
Style Your Site Part 1
Style Your Site Part 1Style Your Site Part 1
Style Your Site Part 1
 
EPiServer Web Parts
EPiServer Web PartsEPiServer Web Parts
EPiServer Web Parts
 
The Future of CSS
The Future of CSSThe Future of CSS
The Future of CSS
 
How Not To Code Flex Applications
How Not To Code Flex ApplicationsHow Not To Code Flex Applications
How Not To Code Flex Applications
 
Microformats HTML to API
Microformats HTML to APIMicroformats HTML to API
Microformats HTML to API
 
Streamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web FrameworksStreamlining Your Applications with Web Frameworks
Streamlining Your Applications with Web Frameworks
 
Even faster web sites presentation 3
Even faster web sites presentation 3Even faster web sites presentation 3
Even faster web sites presentation 3
 
What's New in Web Development
What's New in Web DevelopmentWhat's New in Web Development
What's New in Web Development
 
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service BackendWide Open Spaces Using My Sql As A Web Mapping Service Backend
Wide Open Spaces Using My Sql As A Web Mapping Service Backend
 
Single Page WebApp Architecture
Single Page WebApp ArchitectureSingle Page WebApp Architecture
Single Page WebApp Architecture
 
HTML5 - techMaine Presentation 5/18/09
HTML5 - techMaine Presentation 5/18/09HTML5 - techMaine Presentation 5/18/09
HTML5 - techMaine Presentation 5/18/09
 
Webcast 09/2008 - Silverlight 2 Beta 2
Webcast 09/2008 - Silverlight 2 Beta 2Webcast 09/2008 - Silverlight 2 Beta 2
Webcast 09/2008 - Silverlight 2 Beta 2
 

More from Subramanyan Murali

Location aware Web Applications
Location aware Web ApplicationsLocation aware Web Applications
Location aware Web Applications
Subramanyan Murali
 

More from Subramanyan Murali (17)

Yahoo Mail moving to React
Yahoo Mail moving to ReactYahoo Mail moving to React
Yahoo Mail moving to React
 
Clipboard support on Y! mail
Clipboard support on Y! mailClipboard support on Y! mail
Clipboard support on Y! mail
 
What the Hack??
What the Hack??What the Hack??
What the Hack??
 
Web as a data resource
Web as a data resourceWeb as a data resource
Web as a data resource
 
Is it good to be paranoid ?
Is it good to be paranoid ?Is it good to be paranoid ?
Is it good to be paranoid ?
 
When Why What of WWW
When Why What of WWWWhen Why What of WWW
When Why What of WWW
 
Welcome to University Hack Day @ IIT Chennai
Welcome to University Hack Day @ IIT Chennai Welcome to University Hack Day @ IIT Chennai
Welcome to University Hack Day @ IIT Chennai
 
YUI for your Hacks
YUI for your Hacks YUI for your Hacks
YUI for your Hacks
 
YUI open for all !
YUI open for all !YUI open for all !
YUI open for all !
 
Fixing the developer Mindset
Fixing the developer MindsetFixing the developer Mindset
Fixing the developer Mindset
 
Get me my data !
Get me my data !Get me my data !
Get me my data !
 
Asynchronous Javascript and Rich Internet Aplications
Asynchronous Javascript and Rich Internet AplicationsAsynchronous Javascript and Rich Internet Aplications
Asynchronous Javascript and Rich Internet Aplications
 
Yahoo! Frontend Building Blocks
Yahoo! Frontend Building BlocksYahoo! Frontend Building Blocks
Yahoo! Frontend Building Blocks
 
Location aware Web Applications
Location aware Web ApplicationsLocation aware Web Applications
Location aware Web Applications
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
YUI for your Hacks-IITB
YUI for your Hacks-IITBYUI for your Hacks-IITB
YUI for your Hacks-IITB
 
Yahoo! Geo Technologies-IITD
Yahoo! Geo Technologies-IITDYahoo! Geo Technologies-IITD
Yahoo! Geo Technologies-IITD
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Basics of Rich Internet Applications

  • 1. Basics of Rich Internet Applications Doing things right for the Web 2.0 and beyond Subramanyan Murali Frontend Engineer, YDN Evangelist
  • 2. Overview •  What is Rich Internet Applications ? •  Benefits •  Do things right from the start •  Separation of Concern –  HTML for Markup •  Semantic Markup –  CSS for Presentation •  Class hierarchies •  Cascading –  Javascript for Behavior •  JS libraries Technical Presentation 2
  • 3. Overview … –  Ajax for Data interchange –  Using Libraries to add for Effects –  Choose your data Interchange •  Progressive Enhancement Technical Presentation 3
  • 4. Rich internet Applications 4 Technical Presentation
  • 5. RIA •  Users are dissatisfied with the capabilities and performance of simple HTML-based Web applications •  Need for desktop type interactions •  Bringing Interactivity & Intuitiveness Into Web Applications •  Adds complexity to design, develop, deploy and debug
  • 6. Benefits •  Features that WOW the users •  Lot of processing can be off-loaded to the client •  Adoption spreads rapidly and dramatically •  Improved responsiveness •  Platform independence •  Businesses have more reach to their offerings through Rich web applications. •  Deployments costs are minimal Technical Presentation 6
  • 7. Web development over the years End user expects more from current technologies 7 Technical Presentation
  • 8. Perspective •  Over the years, there have not been too many radical developments in Web technologies •  User demand and expectations is ever changing •  The browser is a very hostile development environment –  The web browser was never designed for rich applications –  Multiple browsers just adds to complexity •  Web developer needs to a unique mix of engineers and Designers
  • 9. Perspective … •  Web development standards are not friendly to rich applications development •  But following standards will ensure stability and standard proofing apps Technical Presentation 9
  • 10. Concepts Tricks / approaches / standards for better web development 10 Technical Presentation
  • 11. Consider <link rel=quot;stylesheetquot; type=quot;text/cssquot; href=“fonts-min.cssquot; /> <body> <div style=‘border:1px solid;’> <a href=‘#’ onClick=“doSomething(this);” id=‘something’>Click</a> <form name=‘sample’ style=‘font-size:10px;’ > <input type=‘text’ name=‘search’ value=‘type text’ onKeyPress=‘check();’ /> <input type=‘submit’ onclick=“validate(this.form);” /> </form> </div> </body> <script type=‘text/javascript’> function doSomething(o) { … } function validate(f) { … } function check() { … } </script>
  • 12. Separation of concern <link rel=quot;stylesheetquot; type=quot;text/cssquot; href=“fonts-min.cssquot; /> <body> <div style=‘border:1px solid;’> <a href=‘#’ onClick=“doSomething(this);” id=‘something’>Click</a> <form name=‘sample’ style=‘font-size:10px;’ > <input type=‘text’ name=‘search’ value=‘type text’ onKeyPress=‘check();’ /> <input type=‘submit’ onclick=“validate(this.form);” /> </form> </div> </body> <script type=‘text/javascript’> function doSomething(o) { … } function validate(f) { … } function check() { … } </script> Technical Presentation 12
  • 13. Separation of concern … <link rel=quot;stylesheetquot; type=quot;text/cssquot; href=“fonts-min.cssquot; /> <body> Ajax  <div style=‘border:1px solid;’> DHTML Effects  <a href=‘#’ onClick=“doSomething(this);” id=‘something’>Click</a> <form name=‘sample’ style=‘font-size:10px;’ > CSS  Javascript  <input type=‘text’ name=‘search’ value=‘type text’ onKeyPress=‘check();’ /> <input type=‘submit’ onclick=“validate(this.form);” /> </form> </div> </body> HTML  <script type=‘text/javascript’> function doSomething(o) { … } Server Side  function validate(f) { … } function check() { … } </script> Data Store  Technical Presentation 13
  • 14. Markup •  Getting Makrup right is very important •  “HTML Provides a means to describe the structure of text-based information in a document” – W3C •  It’s a good practice to follow strict.dtd <!DOCTYPE HTML PUBLIC quot;-//W3C//DTD HTML 4.01//EN” quot;http://www.w3.org/TR/html4/strict.dtdquot;> Technical Presentation 14
  • 15. Markup … •  Just write markup for what you want at that moment –  Never code markup for the future •  Adding many divs and classes and ids to everything does not make a good markup •  Representing content and establishing structure is a good practice –  Split into Headers, Body, footers, navigation etc –  Use Ids and classes to get that distinction Technical Presentation 15
  • 16. Markup … <!-- Splitting into Sections --> <div id='container'> <div class='header'> <div class='headertitle'></div> <div class='closelink'> <img src='close.gif' alt='Close link'> </div> </div> <div class='body'>...</div> <div class='footer'></div> </div> Technical Presentation 16
  • 17. Markup … •  Adding too many DIVs can be termed ‘Divitees’ •  Keep things simple, do not pre estimate number of classes, ids and markup •  Splitting based on semantic meaning of the markup elements is better –  Semantic = Meaning •  Add 'presentation identifiers' for CSS as needed –  Identifiers can be as concise as possible Technical Presentation 17
  • 18. Markup … <!-- Better way to write --> <div id='container'> <h2>Header title <img src='close.gif' alt='Close link'></h2> <div class='bd'>...</div> <div class='ft'></div> </div> •  This is the same representation of data, but is more semantic Technical Presentation 18
  • 19. Markup … •  All elements generate a box –  Block-level elements (div, paragraph, list) are formatted as a principal box, and start on a new line –  Inline elements (span, img, strong) appear within context, with no new line •  Inline boxes should not contain block boxes Technical Presentation 19
  • 20. Markup … padding margin-top Header Text This is Body text. This is Body text. This is Body text. This is Body text. Footer Text margin-bottom padding Technical Presentation 20
  • 21. Cascading Style Sheets •  Styles specified in CSS cascade from parent •  When a child chooses to over ride a CSS attribute, the last given CSS attribute takes precedence •  CSS attributes can specifically be asked to quot;inheritquot; value from ancestor •  If the parent element has many child elements, the class selector for the parent can be used to define styles for its children Technical Presentation 21
  • 22. CSS … <div class='test'> <p>This is test para <span>and test span</></p> <h3>This is test heading </h3> <a href='http://yahoo.com'>Yahoo! Link </a> </div> .test p { /*styles for para tag*/ } .test p span { /*styles for span tag inside para*/ } Technical Presentation 22
  • 23. CSS … •  Inline boxes cannot have dimensions and some other properties declared •  Floating or absolutely positioning any element makes it a block-level element •  CSS has to be separated out –  Presentation styles •  Colors, font sizes, font families –  Positional Styles •  Floats, Positions, Margins, Paddings Technical Presentation 23
  • 24. CSS … •  Normal Flow –  Includes normal positioning and relative positioning for block and inline boxes •  Float Model –  In the float model, a box is first laid out according to the normal flow, then taken out of the flow and shifted to the left or right as far as possible. Content may flow along the side of a float •  Absolute Positioning –  In the absolute positioning model, a box is removed from the normal flow entirely and assigned a position with respect to a containing block. This has no impact on later siblings. Technical Presentation 24
  • 25. CSS … •  Specificity : It is a process used to determine which rules take precedence in CSS when several rules could be applied to the same element in markup •  Specificity calculations aid –  Every id selector (#whatever) = value of 100 –  Every class selector (.whatever) = value of 10 –  Every HTML selector (whatever) = value of 1 –  Add them all up = specificity value •  div p.tree > div p •  body #content .alternative p > div p.tree •  Specificity is irrespective of order Technical Presentation 25
  • 26. CSS … •  Do not use too many CSS hacks –  Most commonly used hacks will be for the Box model differences –  *css-attribute will make the class visible only to IE browsers •  If you are forced to have many CSS hacks, group all of them together –  Using specificity rules, you can override specific styles •  Float model hacks will be the more commonly used Technical Presentation 26
  • 27. CSS … •  CSS design can almost never be got right in the first go –  Need to constantly update the CSS •  Hence, never over design your styles –  Code for what you need, trying to make it as generic as possible •  With clean markup and proper CSS design, flexible Web 2.0 layouts is possible –  Will reduce maintenance costs –  Layout changes are simple •  With demanding Web 2.0 applications, namespacing CSS class names can be important Technical Presentation 27
  • 28. CSS … •  Namespaces can be chosen based on design –  Section names –  Feature –  Style category div.nav-section { } div.nav-link { } div.footer { } •  Do not choose style names that explain what the class does –  Class names should explain what they are meant for Technical Presentation 28
  • 29. CSS … •  CSS Class nesting can be a powerful aid to your design •  When classes are nested, the styles applied will be a union of the the 2 classes •  Class nesting can make the markup more readable .section { padding: 2px 4px; color: black; } .highlight { border: 1px solid; } <div class=‘section highlight’>Test</div> Technical Presentation 29
  • 30. Javascript •  Javascript was primarily used for client side validation •  With the demands of Web 2.0, Javascript is the chosen technology for dynamic scripting on the client to create rich internet applications •  Javascript is Object oriented •  All javascript used on the page needs to be closest to the closing HTML tag as possible •  Client side behaviour is programmed using Javascript Technical Presentation 30
  • 31. Javascript … •  Use a Javascript Library where ever possible –  Libraries are solutions that manage various client side issues centrally –  Cross browser issues are handled by the library •  Do not over design your javascript –  Start simple –  Choose a well known design pattern –  Stick to the design •  Try to reduce the use of Global variables –  In JavaScript the window object is the global scope –  This is the highest scope in the scope chain •  Always namespace your scripts Technical Presentation 31
  • 32. Javascript … •  Simple Namespacing function validate-text() { } function effects_tween(o) { } function effects_animate() { } •  Object Namespace var myApp = {}; myApp.globals = {}; myApp.methods = {}; myApp.methods.multiply = function(a, b) { } Technical Presentation 32
  • 33. Javascript … •  Having a object namespace will allow for easier cleanup during page clean-up or garbage collection window.onunload = function(e) { myApp = null; /* All the properties are cleared */ } •  Namespaces also helps for better code organization •  In the web 2.0 world, there is a lot of code mixing around –  Widgets may exist in other pages –  Namespace can ensure you have complete control over your code execution Technical Presentation 33
  • 34. Javascript … myApp.methods.generate = function ( o ) { }; function generate = function (a, b) { }; •  YUI 2.x uses the YAHOO namespace •  YUI 3.x uses the YUI namespace –  With the change from YAHOO to YUI we are guaranteed not to break backward compatibility. This allows you to use both YUI 2.x and YUI 3.x on the same page without fear of breaking existing code. Technical Presentation 34
  • 35. Javascript … •  Anonymous functions are used to execute code which only needs to be executed once •  In JavaScript, a function can be used wherever expressions can be used •  A function can be passed as a argument in javascript •  If you don't need to re-use the callback function (name), write the function definition directly foo ( somedata, function( ) { // callback function }); Technical Presentation 35
  • 36. Javascript … •  When a nested function has access to the scope of it’s parent function, it is called a closure •  In JavaScript, if the interpreter can’t find a variable in it’s current scope, it’ll go up the scope chain and searches the parent scope until it finds the variable function foo(){ var msg = quot;hello worldquot;; function bar(){ alert(msg); }; bar(); }; foo(); Technical Presentation 36
  • 37. Javascript … •  Inside the scope, the function bar() can be called many times, and each time, it will have access to the variable •  Closure example –  http://indiahacku.in/subram/dataFetch.js Technical Presentation 37
  • 38. Javascript … •  In DHTML, every time a quot;stylequot; gets changed for a visible element, there is an internal reflow happening in the browser. This can slow up a little bit or can cause unnecessary flicker –  Either make the element display:none and apply all styles ( handling height and width may require element be visible ) –  Or detach the element from the parent node, do all manipulation, and re attach the item to the parent Technical Presentation 38
  • 39. Javascript … •  Accessing the quot;stylequot; property of the element every time (in the example), we can cache the property accesses to gain a small performance increase: var d = document.getElementById(quot;containerquot;), e = d.style; e.display = quot;quot;; // make it visible e.background = quot;#fffquot;; e.color = quot;#000quot;; // some more changes to d.style via e Technical Presentation 39
  • 40. Javascript … •  Caching function pointers can give performance improvements •  The global lookup for every iteration can be avoided by rewriting the quot;doMyDutyquot; as: function doMyDuty( collection ) { var i, n = collection.length; var fcn= doStuff; for (i = 0; i < n; i++) { fcn( collection[i] ); } } •  Technical Presentation 40
  • 41. Ajax •  Ajax must be the last layer in a web application •  Core functionality must never reply on Ajax •  Ajax must be extensively used to enhance functionality which reply on data from the server •  Since Javacsript can take up some business logic, we do not need to rely on server side processing –  Raw data can be processed on the client Technical Presentation 41
  • 42. Ajax … •  Ajax should be used to enhance user experience, it should not be the only experience •  Progressively enhance the page –  Introduced to subvert the traditional quot;Graceful Degradationquot; development method •  Get more data as and when user requests and cache it on the client •  When Application has to deal with Bandwidth issues •  Provide a Abort operation where ever possible Technical Presentation 42
  • 43. Ajax … •  Advantages of using Ajax –  Rich User Interface •  User can be more engaged •  User need not load the page everytime to get new information –  Snappier Response Time •  Lesser content can be loaded the first time –  Lower Bandwidth Usage •  No page reloading •  Only data specific to user request can be loaded –  Separation of content, formatting and behaviour Technical Presentation 43
  • 44. Ajax … •  Disadvantages of using Ajax –  Some User Agents may not support Ajax –  Search Engine Optimization gets a hit if not properly designed •  Search engines crawlers may not be smart enough to navigate the Ajax based pages –  Bad Frontend development can hide the URLs of the link that initiate Ajax calls –  Accessibility of the page can be affected •  Problem for users that assume GET requests do not change the state of an application •  Confuses Robots, Spiders •  Shows Bad Design – Designer does not know the difference between GET & POST requests Technical Presentation 44
  • 45. Ajax … •  Any client-side changes to the page (using DHTML) are not recorded in the browser's history –  Yahoo! Browser History Manager can help •  Back/forward buttons do not work well with rich applications that use DHTML, they need to be controlled by the developer •  Cross-domain requests –  Using a server side proxy is the most suitable solution Technical Presentation 45
  • 46. JSON •  JavaScript Object Notation. •  A Data Interchange Format. •  Text-based. •  Light-weight. •  Easy to parse. •  Language Independent. •  A Subset of ECMA-262 ECMAScript Third Edition. Technical Presentation 46
  • 47. JSON … •  Not a document format •  Not a markup language •  Not a general purpose serialization format –  It is perfectly suited for the Web and RIA Technical Presentation 47
  • 48. JSON … •  { “key” : value, ... } •  The “key” is a string •  The “value” can be anything - strings, numbers, boolean, objects, arrays or null Technical Presentation 48
  • 49. JSON … •  MIME type - application/json •  Strictly UNICODE •  Default is UTF-8 •  UTF-16 and UTF-32 are accepted Technical Presentation 49
  • 50. JSON … •  Step 1 : XMLHttpRequest •  Step 2 : Obtain responseText •  Step 3 : Parse the responseText var responseData = eval ( ' ( ' + responseText + ' ) ' ); Technical Presentation 50
  • 51. JSON … •  Available in ECMAScript 4th Edition –  JSON: The Fat-Free Alternative to XML - Douglas Crockford - http://www.json.org/fatfree.html •  New Methods: –  Object.prototype.toJSONString –  String.prototype.parseJSON •  In current versions, it can be used by including JSON.org/json2.js (http://www.json.org/js.html) •  Parse the responseText –  var responseData = JSON.parse(responseText); Technical Presentation 51
  • 52. Cross Browser Support Browser differences are painful 52 Technical Presentation
  • 53. Cross Browser … •  Browsers have differences in standards implementation •  Browsers have Bugs •  Developing for multiple browsers can be a daunting task –  Box model differences –  Support differences –  Javascript performance •  Yahoo!s Graded Browser support details out browsers into 3 grades –  http://developer.yahoo.com/yui/articles/gbs/
  • 54. Cross Browser •  http://www.quirksmode.org/compatibility.html#t01 •  Using CSS and Javascript libraries can be really helpful when dealing with cross browser issues •  Working with a strict doctype will ensure that most browsers work in the standards compliant mode Technical Presentation 54
  • 55. Cross Browser … •  Browsers are not limited to browsers on the computer •  Mobile phones have their own complexities •  With more mobile users, need for rich web applications to run on their respective devices is essential Technical Presentation 55
  • 56. Progressive enhancement First inspect, then provide 56 Technical Presentation
  • 57. Progressive Enhancement “Checking if the ice can carry you before stepping on it” –  Christian Heilmann •  Simply means that you test for an improvement before you apply it •  System design and development methodology makes it possible to build in a layered fashion •  Accessibility and Performance are accounted for right at the start •  Layers should be made to be replaceable - swap the HTML layer with an RSS layer and CSS with XSLT
  • 58. Progressive Enhancement … •  Browser capability testing is done by Nag bars, which retrieve information about the browser prior to sending the actual page •  Progressive enhancement may avoid you the trouble for maintaining different pages for different user agents •  The Interactivity demanded by users and user experience is determined based on the capabilities of devices Technical Presentation 58
  • 59. Progressive Enhancement … •  Build for C grade •  Test for C grade •  Add style and behavior for A grade •  Test for A grade •  Test in X Grade •  Fix for X Grade if needed Technical Presentation 59
  • 61. Thank you 61 Technical Presentation