SlideShare ist ein Scribd-Unternehmen logo
1 von 16
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

Weitere ähnliche Inhalte

Was ist angesagt?

[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JSIvano Malavolta
 
Making Life Easier with PowerShell - SPSRIC
Making Life Easier with PowerShell - SPSRICMaking Life Easier with PowerShell - SPSRIC
Making Life Easier with PowerShell - SPSRICMichael Greene
 
When Sightly Meets Slice by Tomasz Niedźwiedź
When Sightly Meets Slice by Tomasz NiedźwiedźWhen Sightly Meets Slice by Tomasz Niedźwiedź
When Sightly Meets Slice by Tomasz NiedźwiedźAEM HUB
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web appsIvano Malavolta
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVASightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVAYash Mody
 
The Grid the Brad and the Ugly: Using Grids to Improve Your Applications
The Grid the Brad and the Ugly: Using Grids to Improve Your ApplicationsThe Grid the Brad and the Ugly: Using Grids to Improve Your Applications
The Grid the Brad and the Ugly: Using Grids to Improve Your Applicationsbalassaitis
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleKaty Slemon
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowPrabhdeep Singh
 
Modern development paradigms
Modern development paradigmsModern development paradigms
Modern development paradigmsIvano Malavolta
 
JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6JavaOne 2011: Migrating Spring Applications to Java EE 6
JavaOne 2011: Migrating Spring Applications to Java EE 6Bert Ertman
 

Was ist angesagt? (20)

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

Ähnlich wie Rise of the Single Page Application

Introduction to Web Application Clustering
Introduction to Web Application ClusteringIntroduction to Web Application Clustering
Introduction to Web Application ClusteringPiyush Katariya
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsAviran Cohen
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Marco Breveglieri
 
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.WO Community
 
Comparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAsComparing Angular and React JS for SPAs
Comparing Angular and React JS for SPAsJennifer Estrada
 
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014
Using BladeRunnerJS to Build Front-End Apps that Scale - Fluent 2014Phil Leggetter
 
AngularJSTO presentation
AngularJSTO presentationAngularJSTO presentation
AngularJSTO presentationAlan Hietala
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners WorkshopSathish VJ
 
Intro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETIntro to SPA using JavaScript & ASP.NET
Intro to SPA using JavaScript & ASP.NETAlan Hecht
 
Grails patterns and practices
Grails patterns and practicesGrails patterns and practices
Grails patterns and practicespaulbowler
 
Domain Driven Design Javaday Roma2007
Domain Driven Design Javaday Roma2007Domain Driven Design Javaday Roma2007
Domain Driven Design Javaday Roma2007Antonio Terreno
 
Ankor Presentation @ JavaOne San Francisco September 2014
Ankor Presentation @ JavaOne San Francisco September 2014Ankor Presentation @ JavaOne San Francisco September 2014
Ankor Presentation @ JavaOne San Francisco September 2014manolitto
 
How to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that ScaleHow to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that ScalePhil Leggetter
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project Elad Hirsch
 

Ähnlich wie Rise of the Single Page Application (20)

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

Mehr von Piyush Katariya

Concurrency, Parallelism And IO
Concurrency,  Parallelism And IOConcurrency,  Parallelism And IO
Concurrency, Parallelism And IOPiyush Katariya
 
Handling the growth of data
Handling the growth of dataHandling the growth of data
Handling the growth of dataPiyush Katariya
 
JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsPiyush Katariya
 
My inspirations and learned lessons
My inspirations and learned lessonsMy inspirations and learned lessons
My inspirations and learned lessonsPiyush Katariya
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)Piyush Katariya
 

Mehr von Piyush Katariya (8)

Concurrency, Parallelism And IO
Concurrency,  Parallelism And IOConcurrency,  Parallelism And IO
Concurrency, Parallelism And IO
 
Handling the growth of data
Handling the growth of dataHandling the growth of data
Handling the growth of data
 
Expression problem
Expression problemExpression problem
Expression problem
 
JavaScript for Enterprise Applications
JavaScript for Enterprise ApplicationsJavaScript for Enterprise Applications
JavaScript for Enterprise Applications
 
Thinking Functionally
Thinking FunctionallyThinking Functionally
Thinking Functionally
 
My inspirations and learned lessons
My inspirations and learned lessonsMy inspirations and learned lessons
My inspirations and learned lessons
 
What is scala
What is scalaWhat is scala
What is scala
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
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