SlideShare a Scribd company logo
Rise of the Single Page
                                    Application




  Piyush Katariya
  pkatariya@equalexperts.com
© Equal Experts UK Ltd 2011           www.equalexperts.com   1
The traditional web

        • Server
                     • Accept request - controller
                     • Execute business logic – model
                     • Render result object from model – view
                     • Respond to client– The BIG HTML response
        • Client
                     • Wait for The BIG HTML response
                     • Manage resources engaged in the referrer page
                     • Load dependencies - .css, .js, .html etc.
                     • UI Rendering for whole page
                     • Registering default and custom event for page

© Equal Experts UK Ltd 2011                www.equalexperts.com        2
The Smart Client design

        • Server
             • Accept request - controller
             • Execute business logic – model
             • Respond to client– result object
        • Client
             • Keep the initial view display ready
             • Render response with local template
             • UI Rendering for part of logical view
             • Registering default and custom event only for
               logical view

© Equal Experts UK Ltd 2011            www.equalexperts.com    3
The Alternatives




© Equal Experts UK Ltd 2011        www.equalexperts.com   4
The JavaScript Language

        • Supported by all web browsers
        • Prototypal inheritance
        • Supports OOP out of the box
        • functional
        • Loosely typed, interpreted
        • Everything is object, just make it var
        • Objects are nothing but collection of key value
          pairs

© Equal Experts UK Ltd 2011       www.equalexperts.com      5
Godfather of JSON says


        “ JavaScript is the only language in the world
          which has lots of bad parts and good parts and
          lots of stuffs which falls in between. But if you
          concentrate on only good parts while
          development this language has no alternative ! ”
                               - Douglas Crockford during TechTalk on JS




© Equal Experts UK Ltd 2011                    www.equalexperts.com        6
Good parts - JSON

        • Creation
                     var jsonObject = new Object() ;
                     var jsonObject = { } ;
                     var jsonObject = { “awesome” : true };
                     var jsonObject = Object.create(parentJsonObject);

        • Adding properties
                     jsonObject.propertyName = “value”;
                     jsonObject[“propertyName”] = “value”;
                     jsonObject.someFunction = function() { // definition};
                     jsonObject[“someFunction”] = function() { // definition };


© Equal Experts UK Ltd 2011                      www.equalexperts.com             7
Good parts - functions

        •     First class objects
        •     Can be invoked, passed as arg and can be returned
        •     There is no overloading !
        •     Definitions
                     var add = new Function( 'a', 'b', 'return a+b');
                     var add = function( a, b) { return a+b; } ;
                     function add(a, b) { return a+b; }
        • Blessed with
                     • this
                     • arguments


© Equal Experts UK Ltd 2011                www.equalexperts.com         8
Good parts – function as
                                 a class
           function Class() {

                   var privateMemberVar="I am private member";
                   var privateMemberFunction= function(){
                       return "I am private method";
                   };

                   this.memberVar = "I am public member";
                   this.memberFunction = function() {
                        return "I am public method ";
                   };
           }

           var object = new Class();




© Equal Experts UK Ltd 2011                  www.equalexperts.com   9
Good parts - closures
                 var counterModule = ( function( ) {

                          var privateCount = 0;

                          function changeBy(val) {
                              return privateCount += val;
                          }

                        return {
                            increment : function() {
                                 changeBy(1);
                            },
                            decrement : function() {
                                 changeBy(-1);
                            },
                            currentValue : function() {
                                 return privateCount;
                            }
                        };
                 } ) ( );

© Equal Experts UK Ltd 2011                       www.equalexperts.com   10
Abstract Browser Engine
                                          Browser


                                          Work Queue


                              UI Thread                            DOM



                              JS Engine                  Layout Engine




                                            OS


                              CPU                                  GPU



© Equal Experts UK Ltd 2011                 www.equalexperts.com         11
Enter the SPA

        Fragrances and Scents

         jquery – DOM aroma
         require.js – AMD aroma
         Handlebars.js – template aroma
         underscore.js – utility aroma
              workshop app url - http://goo.gl/31ho4




© Equal Experts UK Ltd 2011                  www.equalexperts.com   12
Responsive UI – UX

        • Resource Loading
                     •        Pre - .css
                     •        Post - .js, iframes, heavy images, flash, adds

        • No hard clicks please !
        • Flirt with client side templates
        • <script> should always be the last child of <body>
        • Batch DOM queries by { “type” : [„select‟, „update‟] }
        • Have you heard about DocumentFragments?
        • Lazy load iframes, avoid them altogether if possible
        • Minimize the Reflows and Repaints
        • Divide and rule the heavy JavaScript tasks
        • Progressive Enhancement and Graceful Degradation

© Equal Experts UK Ltd 2011                               www.equalexperts.com   13
Responsive UI - Application

        • Minify the .js
        • AMD loaders
        • Image Sprites
        • Reduce DNS Lookups
        • Expires and Cache-Control HTTP Header
        • CDN – proximity and bandwidth matters
        • gzip it !


© Equal Experts UK Ltd 2011    www.equalexperts.com   14
If you love our SPA, then do visit again.



        Did we missed any fragrances ?



© Equal Experts UK Ltd 2011   www.equalexperts.com   15
© Equal Experts UK Ltd 2011   www.equalexperts.com   16

More Related Content

PPTX
Making Life Easier with PowerShell (SPSVB 2012)
PPTX
MWLUG 2015 - AD114 Take Your XPages Development to the Next Level
PDF
React && React Native workshop
PDF
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
PDF
Java EE 8 Recipes
PPTX
Mastering the Sling Rewriter
PDF
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
PDF
Web Components v1
Making Life Easier with PowerShell (SPSVB 2012)
MWLUG 2015 - AD114 Take Your XPages Development to the Next Level
React && React Native workshop
RESTful OSGi Web Applications Tutorial - Khawaja S Shams & Jeff Norris
Java EE 8 Recipes
Mastering the Sling Rewriter
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
Web Components v1

What's hot (20)

PDF
[2015/2016] Require JS and Handlebars JS
PPTX
Making Life Easier with PowerShell - SPSRIC
PPTX
When Sightly Meets Slice by Tomasz Niedźwiedź
PDF
Local storage in Web apps
KEY
Offline Html5 3days
PDF
Sightly - AEM6 UI Development using JS and JAVA
PDF
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
PDF
PDF
Wt unit 1 ppts web development process
PDF
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
PPTX
The Grid the Brad and the Ugly: Using Grids to Improve Your Applications
PDF
Introduction to JavaScript
PDF
Laravel 8 export data as excel file with example
PPTX
PPTX
HTL(Sightly) - All you need to know
PDF
Java EE 7 - Overview and Status
PDF
20jsp
PDF
Modern development paradigms
PDF
JavaOne 2011: Migrating Spring Applications to Java EE 6
PDF
[2015/2016] Require JS and Handlebars JS
Making Life Easier with PowerShell - SPSRIC
When Sightly Meets Slice by Tomasz Niedźwiedź
Local storage in Web apps
Offline Html5 3days
Sightly - AEM6 UI Development using JS and JAVA
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
Wt unit 1 ppts web development process
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
The Grid the Brad and the Ugly: Using Grids to Improve Your Applications
Introduction to JavaScript
Laravel 8 export data as excel file with example
HTL(Sightly) - All you need to know
Java EE 7 - Overview and Status
20jsp
Modern development paradigms
JavaOne 2011: Migrating Spring Applications to Java EE 6
Ad

Similar to Rise of the Single Page Application (20)

PPTX
JS Essence
PDF
PPTX
Introduction to Web Application Clustering
PPTX
ME vs WEB - AngularJS Fundamentals
PDF
Web Development with Delphi and React - ITDevCon 2016
PDF
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
PPTX
Comparing Angular and React JS for SPAs
PDF
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
PDF
Aleact
PDF
AngularJSTO presentation
PPTX
AngularJS Beginners Workshop
PPT
Intro to SPA using JavaScript & ASP.NET
PDF
Grails patterns and practices
PDF
Domain Driven Design Javaday Roma2007
PPTX
Ankor Presentation @ JavaOne San Francisco September 2014
PPTX
react-slides.pptx
PDF
How to Build Single Page HTML5 Apps that Scale
PDF
Eclipse e4
PPTX
Angular or React
PPTX
AngularJS - Architecture decisions in a large project 
JS Essence
Introduction to Web Application Clustering
ME vs WEB - AngularJS Fundamentals
Web Development with Delphi and React - ITDevCon 2016
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Comparing Angular and React JS for SPAs
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Aleact
AngularJSTO presentation
AngularJS Beginners Workshop
Intro to SPA using JavaScript & ASP.NET
Grails patterns and practices
Domain Driven Design Javaday Roma2007
Ankor Presentation @ JavaOne San Francisco September 2014
react-slides.pptx
How to Build Single Page HTML5 Apps that Scale
Eclipse e4
Angular or React
AngularJS - Architecture decisions in a large project 
Ad

More from Piyush Katariya (8)

PDF
Concurrency, Parallelism And IO
PDF
Handling the growth of data
PDF
Expression problem
PDF
JavaScript for Enterprise Applications
PDF
Thinking Functionally
PDF
My inspirations and learned lessons
PPTX
What is scala
PPTX
JavaScript (without DOM)
Concurrency, Parallelism And IO
Handling the growth of data
Expression problem
JavaScript for Enterprise Applications
Thinking Functionally
My inspirations and learned lessons
What is scala
JavaScript (without DOM)

Rise of the Single Page Application

  • 1. Rise of the Single Page Application Piyush Katariya pkatariya@equalexperts.com © Equal Experts UK Ltd 2011 www.equalexperts.com 1
  • 2. The traditional web • Server • Accept request - controller • Execute business logic – model • Render result object from model – view • Respond to client– The BIG HTML response • Client • Wait for The BIG HTML response • Manage resources engaged in the referrer page • Load dependencies - .css, .js, .html etc. • UI Rendering for whole page • Registering default and custom event for page © Equal Experts UK Ltd 2011 www.equalexperts.com 2
  • 3. The Smart Client design • Server • Accept request - controller • Execute business logic – model • Respond to client– result object • Client • Keep the initial view display ready • Render response with local template • UI Rendering for part of logical view • Registering default and custom event only for logical view © Equal Experts UK Ltd 2011 www.equalexperts.com 3
  • 4. The Alternatives © Equal Experts UK Ltd 2011 www.equalexperts.com 4
  • 5. The JavaScript Language • Supported by all web browsers • Prototypal inheritance • Supports OOP out of the box • functional • Loosely typed, interpreted • Everything is object, just make it var • Objects are nothing but collection of key value pairs © Equal Experts UK Ltd 2011 www.equalexperts.com 5
  • 6. Godfather of JSON says “ JavaScript is the only language in the world which has lots of bad parts and good parts and lots of stuffs which falls in between. But if you concentrate on only good parts while development this language has no alternative ! ” - Douglas Crockford during TechTalk on JS © Equal Experts UK Ltd 2011 www.equalexperts.com 6
  • 7. Good parts - JSON • Creation var jsonObject = new Object() ; var jsonObject = { } ; var jsonObject = { “awesome” : true }; var jsonObject = Object.create(parentJsonObject); • Adding properties jsonObject.propertyName = “value”; jsonObject[“propertyName”] = “value”; jsonObject.someFunction = function() { // definition}; jsonObject[“someFunction”] = function() { // definition }; © Equal Experts UK Ltd 2011 www.equalexperts.com 7
  • 8. Good parts - functions • First class objects • Can be invoked, passed as arg and can be returned • There is no overloading ! • Definitions var add = new Function( 'a', 'b', 'return a+b'); var add = function( a, b) { return a+b; } ; function add(a, b) { return a+b; } • Blessed with • this • arguments © Equal Experts UK Ltd 2011 www.equalexperts.com 8
  • 9. Good parts – function as a class function Class() { var privateMemberVar="I am private member"; var privateMemberFunction= function(){ return "I am private method"; }; this.memberVar = "I am public member"; this.memberFunction = function() { return "I am public method "; }; } var object = new Class(); © Equal Experts UK Ltd 2011 www.equalexperts.com 9
  • 10. Good parts - closures var counterModule = ( function( ) { var privateCount = 0; function changeBy(val) { return privateCount += val; } return { increment : function() { changeBy(1); }, decrement : function() { changeBy(-1); }, currentValue : function() { return privateCount; } }; } ) ( ); © Equal Experts UK Ltd 2011 www.equalexperts.com 10
  • 11. Abstract Browser Engine Browser Work Queue UI Thread DOM JS Engine Layout Engine OS CPU GPU © Equal Experts UK Ltd 2011 www.equalexperts.com 11
  • 12. Enter the SPA Fragrances and Scents  jquery – DOM aroma  require.js – AMD aroma  Handlebars.js – template aroma  underscore.js – utility aroma workshop app url - http://goo.gl/31ho4 © Equal Experts UK Ltd 2011 www.equalexperts.com 12
  • 13. Responsive UI – UX • Resource Loading • Pre - .css • Post - .js, iframes, heavy images, flash, adds • No hard clicks please ! • Flirt with client side templates • <script> should always be the last child of <body> • Batch DOM queries by { “type” : [„select‟, „update‟] } • Have you heard about DocumentFragments? • Lazy load iframes, avoid them altogether if possible • Minimize the Reflows and Repaints • Divide and rule the heavy JavaScript tasks • Progressive Enhancement and Graceful Degradation © Equal Experts UK Ltd 2011 www.equalexperts.com 13
  • 14. Responsive UI - Application • Minify the .js • AMD loaders • Image Sprites • Reduce DNS Lookups • Expires and Cache-Control HTTP Header • CDN – proximity and bandwidth matters • gzip it ! © Equal Experts UK Ltd 2011 www.equalexperts.com 14
  • 15. If you love our SPA, then do visit again. Did we missed any fragrances ? © Equal Experts UK Ltd 2011 www.equalexperts.com 15
  • 16. © Equal Experts UK Ltd 2011 www.equalexperts.com 16