SlideShare uma empresa Scribd logo
1 de 47
Baixar para ler offline
00 Web App Essentials
A complete toolbox set for creation middle-
size single-page application (SPA)




                                                                             by
                                                        Sergey N. Bolshchikov
                                                         http://bolshchikov.net
                                       sergey.bolshchikov@new-proimage.com
                                                         New ProImage, 2012
Outline
1. Premises
   a. Problems it solves
   b. Solution
   c. New Problems and Solutions
                                           Premises
2. Structure                             (Background)
   a. Architecture
   b. Routing
   c. MVC
   d. Templating
3. Performance
                                          SPA
   a. UI Rendering
                                   Structure    Performance
   b. Modules
        i. AMD
       ii. Compilation
4. Library
SPA Premises
Problems it solves




   Bad UX: reload of UI parts   Performance
Solution

 Navigation Bar - 20%



                        Toolbar - 10%



 Menu -                                 AJAX
 20%
                        Content - 40%




 Footer - 10%
New Problems & Solutions
                              Problems
                                          Ajax callbacks
         http://mysite.com              HTML strings in JS
             Static address                     Spaghetti code




http://mysite.com/#/              MVC                            Templating
                                                                 Javascript-HTML
       Routing                Data-Logic-View                    (Dynamic-Static)



                              Solutions
Structure:
Architecture
SPA Architecture
        Server                     Browser Address Bar




       xhr                             Routing Ctrl




             Ctrl 1                         Ctrl 2                      Ctrl 3
 MVC                               MVC                        MVC
  Mdl 1               Tpl 1         Mdl 2             Tpl 2     Mdl 3            Tpl 3




                          View 1                              View 2
                                         HTML Container
SPA Architecture
        Server                     Browser Address Bar




       xhr                             Routing Ctrl




             Ctrl 1                         Ctrl 2                      Ctrl 3
 MVC                               MVC                        MVC
  Mdl 1               Tpl 1         Mdl 2             Tpl 2     Mdl 3            Tpl 3




                          View 1                              View 3
                                         HTML Container
Routing: why?

     No Page         Direct
    Refreshing     Navigation




                     Link
    Bookmark        Sharing



   URI: http://www.mysite.com
Routing: how?

 http://www.myside.com/#/folder/bolshchikov

            Hash-based Solution



  http://www.myside.com/folder/bolshchikov

    pushState Solution(HTML5 History API)
Routing Example
$.Controller('Routing', {

           init: function() {
                $('.header').explorer_header_create();
                $('#toolbar').explorer_toolbar_create();
                $('#tree ul li').explorer_tree_create(null);
                $('.footer').explorer_footer_create();
           },
           "/folder/:name route": function(data) {
                $('#content').empty();
                $('#content').append('<div id="folder"></div>')
                $('#folder').explorer_list_create(data.name);
           }
      });
new Routing(document.body);
Routing: who?
Almost every modern JS MVC Framework has
implementation of routing:

●   AngularJS
●   BackboneJS
●   JavascriptMVC
●   EmberJS
●   SammyJS
Architecture Pattern MVC
MVC provides clean separation of concerns of

● data (Model)

● presentation (View)

● user input (Controller)
Model

● Represents knowledge or data

● Talks to the server using RESTful
  architecture

● Isolated from controllers and views

● Can be gathered into groups (collections)
Model Example
$.Model('Explorer.Models.Tree',
    {
        data: [ ],
        init: function() {
              var self = this;
              $.ajax({
                   url: 'json/structure.json',
                   dataType: 'json',
                   success: function(data) {
                          for (var i=0; i < data.length; i++) {
                               if (data[i].type === 'folder') {
                                     self.data.push(data[i]);
                               }
                          }
                   }
              });
        }
    }
View

● Considered to be specific element of UI
  ○ Table record might be view
  ○ Composite views

● Is generated from Template

● One model might have multiple views
Controller

● Glue between Model and View

● Handles user interactions

● Might perform business logic role

The role of controller greatly varies from
framework to framework
Controller Example
$.Controller('Explorer.List.Create',
   {
       init: function(el, folder) {
            ...
       },
       'a click': function(a, ev) {
            var el = null;
            for(var i = 0; i < list.data.length; i++) {
                 if (list.data[i].name === a.text()) {
                       el = list.data[i];
                       break;
                 }
            }
            $('.modal').explorer_details_create(el);
       }
   }
MVC: who?
Major player in the world of JS MVC Frameworks:
● AngularJS
● Backbone (MV*)
● EmberJS
● Dojo
● JavascriptMVC
● Knockout (MVVM)

All of them (probably, besides JavascriptMVC) doesn't
implement MVC pattern in classical way. Each has its own
vision.
They all are MV*
Templating: before


                         Javascript
     HTML                Document
    Document
               changes    JS Code


                         HTML Code
Templating: how?

                                    tpl.html
 Data
                 Templating
                   Engine




        1.html     2.html     ...      n.html
Templating: after
Separation of              HTML
Concerns                  Template
                                retrieve




   HTML                   Javascript
                          Document
  Document
                changes
                          JS Code
Template Example (EJS)
 <tbody>
  <% for (var i = 0; i < this.length; i++) { %>
    <tr>
     <td><%= this[i].uid%></td>
     <td><img class="thumb" src="img/<%= this[i].type%>.
png" /></td>
     <td><a href="#"><%= this[i].name%></a></td>
     <td><%= this[i].size%></td>
     <td><%= this[i].owner%></td>
     <td><%= this[i].ctime%></td>
    </tr>
  <% } %>
 </tbody>
Templating: who?
A lot.

●   UnderscoreJS templating    <li><%= name%></li>
●   Handlebars                 <li>{{name}}</li>
●   Mustache                   <li>{{name}}</li>
●   Google Closure Templates   <li>{$name}</li>
●   EJS                        <li><%= name%></li>
●   DustJS
●   ....
Performance:
Module
Modules in JS
   Javascript file            Javascript file

    Function A                 Function A
                          Module A

    Function B
                     VS        Function B



    Function C                 Function C
                          Module B

    Function D                 Function D
Modules in JS
         Defining
         module
        mechanism     Importing
                       module
                     mechanism
           Privacy
Modules in JS
         Defining
         module
        mechanism     Importing
                       module
                     mechanism
           Privacy
Modules in JS
         Defining    Module Pattern
         module
        mechanism       Importing
                         module
                       mechanism
           Privacy
Modules in JS
         Defining     Module Pattern
         module
        mechanism        Importing
                          module
                        mechanism
           Privacy




                     BUT
Modules in JS
                          Javascript file
   Javascript file
                            Module A
     Module A



     Module B
                     VS   Javascript file

                            Module A

     Module C

                          Javascript file
     Module D
                            Module A
UI Rendering
                               time



 HTML      Javascript   HTML
UI Rendering
                               time



 HTML      Javascript   HTML
UI Rendering
                                              time



 HTML            Javascript            HTML


         JS       JS           JS
 HTML                                  HTML
        Module   Module       Module
UI Rendering
                                              time



 HTML            Javascript            HTML


         JS       JS           JS
 HTML                                  HTML
        Module   Module       Module
UI Rendering
                                                       time



 HTML             Javascript                  HTML


         JS        JS             JS
 HTML                                         HTML
        Module    Module         Module


                         JS           JS       JS
 HTML      HTML
                        Module       Module   Module
UI Rendering
                                                       time



 HTML             Javascript                  HTML


         JS        JS             JS
 HTML                                         HTML
        Module    Module         Module


                         JS           JS       JS
 HTML      HTML
                        Module       Module   Module
UI Rendering
                                                            time



 HTML             Javascript                      HTML


         JS        JS             JS
 HTML                                             HTML
        Module    Module         Module


                         JS           JS            JS
 HTML      HTML
                        Module       Module        Module

                                               JS
                                              Module
                         JS
 HTML      HTML
                        Module
                                               JS
                                              Module
Async Module Definition




  Mechanism for                          Suits where sync
 defining modules    Non-blocking      loading causes bad
and dependencies    parallel loading       performance
AMD: who?

● RequireJS

● curl.js

● Almond

● StealJS
Compilation




                   Reduce the script
Check for syntax         size            Intellectual
   mistakes         (minify, unify)    Property (uglify)
Compilation: who?

● Google Closure

● RequireJS

● StealJS

● YUI Compressor
Library
Base Library




Pure JS Example   VS   jQuery Example
Questions?
Thank you

Mais conteúdo relacionado

Mais procurados

안드로이드 데이터 바인딩
안드로이드 데이터 바인딩안드로이드 데이터 바인딩
안드로이드 데이터 바인딩GDG Korea
 
Graphiti and GMF Compared
Graphiti and GMF ComparedGraphiti and GMF Compared
Graphiti and GMF Comparedkoentsje
 
01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript DevelopmentTommy Vercety
 
Week 8
Week 8Week 8
Week 8A VD
 
Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module PatternsNicholas Jansma
 
MVC pattern for widgets
MVC pattern for widgetsMVC pattern for widgets
MVC pattern for widgetsBehnam Taraghi
 
Introducción a XAML y MVVM
Introducción a XAML y MVVMIntroducción a XAML y MVVM
Introducción a XAML y MVVMSorey García
 
"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил АнохинFwdays
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1Paras Mendiratta
 
Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"Fwdays
 
Part 2
Part 2Part 2
Part 2A VD
 
Dynamic Groovy Edges
Dynamic Groovy EdgesDynamic Groovy Edges
Dynamic Groovy EdgesJimmy Ray
 
Large-Scale JavaScript Development
Large-Scale JavaScript DevelopmentLarge-Scale JavaScript Development
Large-Scale JavaScript DevelopmentAddy Osmani
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09Daniel Bryant
 
JavaScript Modules in Practice
JavaScript Modules in PracticeJavaScript Modules in Practice
JavaScript Modules in PracticeMaghdebura
 

Mais procurados (20)

안드로이드 데이터 바인딩
안드로이드 데이터 바인딩안드로이드 데이터 바인딩
안드로이드 데이터 바인딩
 
Graphiti and GMF Compared
Graphiti and GMF ComparedGraphiti and GMF Compared
Graphiti and GMF Compared
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript Development
 
Week 8
Week 8Week 8
Week 8
 
javascript examples
javascript examplesjavascript examples
javascript examples
 
Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module Patterns
 
Patterns In-Javascript
Patterns In-JavascriptPatterns In-Javascript
Patterns In-Javascript
 
MVC pattern for widgets
MVC pattern for widgetsMVC pattern for widgets
MVC pattern for widgets
 
Introducción a XAML y MVVM
Introducción a XAML y MVVMIntroducción a XAML y MVVM
Introducción a XAML y MVVM
 
"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
 
Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"
 
Part 2
Part 2Part 2
Part 2
 
Dynamic Groovy Edges
Dynamic Groovy EdgesDynamic Groovy Edges
Dynamic Groovy Edges
 
Large-Scale JavaScript Development
Large-Scale JavaScript DevelopmentLarge-Scale JavaScript Development
Large-Scale JavaScript Development
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
 
Knockout js session
Knockout js sessionKnockout js session
Knockout js session
 
Jquery
JqueryJquery
Jquery
 
JavaScript Modules in Practice
JavaScript Modules in PracticeJavaScript Modules in Practice
JavaScript Modules in Practice
 

Semelhante a Complete toolbox for middle-size SPA creation

Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVCAcquisio
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
Wei ding(resume)
Wei ding(resume)Wei ding(resume)
Wei ding(resume)WEI DING
 
Gnizr Architecture (for developers)
Gnizr Architecture (for developers)Gnizr Architecture (for developers)
Gnizr Architecture (for developers)hchen1
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsSoós Gábor
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'sAntônio Roberto Silva
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.jsBert Wijnants
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteRavi Bhadauria
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-senseBen Lin
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introductionCommit University
 
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009ken.egozi
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)Daniel Bryant
 
Intro to MVC 3 for Government Developers
Intro to MVC 3 for Government DevelopersIntro to MVC 3 for Government Developers
Intro to MVC 3 for Government DevelopersFrank La Vigne
 
e-suap - client technologies- english version
e-suap - client technologies- english versione-suap - client technologies- english version
e-suap - client technologies- english versionSabino Labarile
 
ASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web developmentASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web developmentVolodymyr Voytyshyn
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember Chandra Sekar
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatiasapientindia
 

Semelhante a Complete toolbox for middle-size SPA creation (20)

Web 2.0
Web 2.0Web 2.0
Web 2.0
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVC
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
Rails入门培训
Rails入门培训Rails入门培训
Rails入门培训
 
Wei ding(resume)
Wei ding(resume)Wei ding(resume)
Wei ding(resume)
 
Gnizr Architecture (for developers)
Gnizr Architecture (for developers)Gnizr Architecture (for developers)
Gnizr Architecture (for developers)
 
BackboneJS + ReactJS
BackboneJS + ReactJSBackboneJS + ReactJS
BackboneJS + ReactJS
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-sense
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introduction
 
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
 
Intro to MVC 3 for Government Developers
Intro to MVC 3 for Government DevelopersIntro to MVC 3 for Government Developers
Intro to MVC 3 for Government Developers
 
e-suap - client technologies- english version
e-suap - client technologies- english versione-suap - client technologies- english version
e-suap - client technologies- english version
 
ASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web developmentASP.NET MVC as the next step in web development
ASP.NET MVC as the next step in web development
 
Create an application with ember
Create an application with ember Create an application with ember
Create an application with ember
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatia
 

Mais de Sergey Bolshchikov

Onboarding for Software Engineers Done Right
Onboarding for Software Engineers Done RightOnboarding for Software Engineers Done Right
Onboarding for Software Engineers Done RightSergey Bolshchikov
 
Microservices on the client side
Microservices on the client sideMicroservices on the client side
Microservices on the client sideSergey Bolshchikov
 
Values & Culture of Continuous Deliver
Values & Culture of Continuous DeliverValues & Culture of Continuous Deliver
Values & Culture of Continuous DeliverSergey Bolshchikov
 
Continuous Delivery for Front-End Engineers
Continuous Delivery for Front-End EngineersContinuous Delivery for Front-End Engineers
Continuous Delivery for Front-End EngineersSergey Bolshchikov
 
Зачем нужен EmberJS, если мне хвататет jQuery
Зачем нужен EmberJS, если мне хвататет jQueryЗачем нужен EmberJS, если мне хвататет jQuery
Зачем нужен EmberJS, если мне хвататет jQuerySergey Bolshchikov
 
Ember Reusable Components and Widgets
Ember Reusable Components and WidgetsEmber Reusable Components and Widgets
Ember Reusable Components and WidgetsSergey Bolshchikov
 
Front End Development: The Important Parts
Front End Development: The Important PartsFront End Development: The Important Parts
Front End Development: The Important PartsSergey Bolshchikov
 
Web Projects: From Theory To Practice
Web Projects: From Theory To PracticeWeb Projects: From Theory To Practice
Web Projects: From Theory To PracticeSergey Bolshchikov
 

Mais de Sergey Bolshchikov (14)

Onboarding for Software Engineers Done Right
Onboarding for Software Engineers Done RightOnboarding for Software Engineers Done Right
Onboarding for Software Engineers Done Right
 
Pragmatic React Workshop
Pragmatic React WorkshopPragmatic React Workshop
Pragmatic React Workshop
 
Microservices on the client side
Microservices on the client sideMicroservices on the client side
Microservices on the client side
 
ES2015 Quiz
ES2015 QuizES2015 Quiz
ES2015 Quiz
 
Talking code: How To
Talking code: How ToTalking code: How To
Talking code: How To
 
Values & Culture of Continuous Deliver
Values & Culture of Continuous DeliverValues & Culture of Continuous Deliver
Values & Culture of Continuous Deliver
 
Protractor: Tips & Tricks
Protractor: Tips & TricksProtractor: Tips & Tricks
Protractor: Tips & Tricks
 
Continuous Delivery for Front-End Engineers
Continuous Delivery for Front-End EngineersContinuous Delivery for Front-End Engineers
Continuous Delivery for Front-End Engineers
 
Зачем нужен EmberJS, если мне хвататет jQuery
Зачем нужен EmberJS, если мне хвататет jQueryЗачем нужен EmberJS, если мне хвататет jQuery
Зачем нужен EmberJS, если мне хвататет jQuery
 
Ember Reusable Components and Widgets
Ember Reusable Components and WidgetsEmber Reusable Components and Widgets
Ember Reusable Components and Widgets
 
Front End Development: The Important Parts
Front End Development: The Important PartsFront End Development: The Important Parts
Front End Development: The Important Parts
 
Web Projects: From Theory To Practice
Web Projects: From Theory To PracticeWeb Projects: From Theory To Practice
Web Projects: From Theory To Practice
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
 
Backbone Basics with Examples
Backbone Basics with ExamplesBackbone Basics with Examples
Backbone Basics with Examples
 

Último

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 

Último (20)

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 

Complete toolbox for middle-size SPA creation

  • 1. 00 Web App Essentials A complete toolbox set for creation middle- size single-page application (SPA) by Sergey N. Bolshchikov http://bolshchikov.net sergey.bolshchikov@new-proimage.com New ProImage, 2012
  • 2. Outline 1. Premises a. Problems it solves b. Solution c. New Problems and Solutions Premises 2. Structure (Background) a. Architecture b. Routing c. MVC d. Templating 3. Performance SPA a. UI Rendering Structure Performance b. Modules i. AMD ii. Compilation 4. Library
  • 4. Problems it solves Bad UX: reload of UI parts Performance
  • 5. Solution Navigation Bar - 20% Toolbar - 10% Menu - AJAX 20% Content - 40% Footer - 10%
  • 6. New Problems & Solutions Problems Ajax callbacks http://mysite.com HTML strings in JS Static address Spaghetti code http://mysite.com/#/ MVC Templating Javascript-HTML Routing Data-Logic-View (Dynamic-Static) Solutions
  • 8. SPA Architecture Server Browser Address Bar xhr Routing Ctrl Ctrl 1 Ctrl 2 Ctrl 3 MVC MVC MVC Mdl 1 Tpl 1 Mdl 2 Tpl 2 Mdl 3 Tpl 3 View 1 View 2 HTML Container
  • 9. SPA Architecture Server Browser Address Bar xhr Routing Ctrl Ctrl 1 Ctrl 2 Ctrl 3 MVC MVC MVC Mdl 1 Tpl 1 Mdl 2 Tpl 2 Mdl 3 Tpl 3 View 1 View 3 HTML Container
  • 10. Routing: why? No Page Direct Refreshing Navigation Link Bookmark Sharing URI: http://www.mysite.com
  • 11. Routing: how? http://www.myside.com/#/folder/bolshchikov Hash-based Solution http://www.myside.com/folder/bolshchikov pushState Solution(HTML5 History API)
  • 12. Routing Example $.Controller('Routing', { init: function() { $('.header').explorer_header_create(); $('#toolbar').explorer_toolbar_create(); $('#tree ul li').explorer_tree_create(null); $('.footer').explorer_footer_create(); }, "/folder/:name route": function(data) { $('#content').empty(); $('#content').append('<div id="folder"></div>') $('#folder').explorer_list_create(data.name); } }); new Routing(document.body);
  • 13. Routing: who? Almost every modern JS MVC Framework has implementation of routing: ● AngularJS ● BackboneJS ● JavascriptMVC ● EmberJS ● SammyJS
  • 14. Architecture Pattern MVC MVC provides clean separation of concerns of ● data (Model) ● presentation (View) ● user input (Controller)
  • 15. Model ● Represents knowledge or data ● Talks to the server using RESTful architecture ● Isolated from controllers and views ● Can be gathered into groups (collections)
  • 16. Model Example $.Model('Explorer.Models.Tree', { data: [ ], init: function() { var self = this; $.ajax({ url: 'json/structure.json', dataType: 'json', success: function(data) { for (var i=0; i < data.length; i++) { if (data[i].type === 'folder') { self.data.push(data[i]); } } } }); } }
  • 17. View ● Considered to be specific element of UI ○ Table record might be view ○ Composite views ● Is generated from Template ● One model might have multiple views
  • 18. Controller ● Glue between Model and View ● Handles user interactions ● Might perform business logic role The role of controller greatly varies from framework to framework
  • 19. Controller Example $.Controller('Explorer.List.Create', { init: function(el, folder) { ... }, 'a click': function(a, ev) { var el = null; for(var i = 0; i < list.data.length; i++) { if (list.data[i].name === a.text()) { el = list.data[i]; break; } } $('.modal').explorer_details_create(el); } }
  • 20. MVC: who? Major player in the world of JS MVC Frameworks: ● AngularJS ● Backbone (MV*) ● EmberJS ● Dojo ● JavascriptMVC ● Knockout (MVVM) All of them (probably, besides JavascriptMVC) doesn't implement MVC pattern in classical way. Each has its own vision. They all are MV*
  • 21. Templating: before Javascript HTML Document Document changes JS Code HTML Code
  • 22. Templating: how? tpl.html Data Templating Engine 1.html 2.html ... n.html
  • 23. Templating: after Separation of HTML Concerns Template retrieve HTML Javascript Document Document changes JS Code
  • 24. Template Example (EJS) <tbody> <% for (var i = 0; i < this.length; i++) { %> <tr> <td><%= this[i].uid%></td> <td><img class="thumb" src="img/<%= this[i].type%>. png" /></td> <td><a href="#"><%= this[i].name%></a></td> <td><%= this[i].size%></td> <td><%= this[i].owner%></td> <td><%= this[i].ctime%></td> </tr> <% } %> </tbody>
  • 25. Templating: who? A lot. ● UnderscoreJS templating <li><%= name%></li> ● Handlebars <li>{{name}}</li> ● Mustache <li>{{name}}</li> ● Google Closure Templates <li>{$name}</li> ● EJS <li><%= name%></li> ● DustJS ● ....
  • 27. Modules in JS Javascript file Javascript file Function A Function A Module A Function B VS Function B Function C Function C Module B Function D Function D
  • 28. Modules in JS Defining module mechanism Importing module mechanism Privacy
  • 29. Modules in JS Defining module mechanism Importing module mechanism Privacy
  • 30. Modules in JS Defining Module Pattern module mechanism Importing module mechanism Privacy
  • 31. Modules in JS Defining Module Pattern module mechanism Importing module mechanism Privacy BUT
  • 32. Modules in JS Javascript file Javascript file Module A Module A Module B VS Javascript file Module A Module C Javascript file Module D Module A
  • 33. UI Rendering time HTML Javascript HTML
  • 34. UI Rendering time HTML Javascript HTML
  • 35. UI Rendering time HTML Javascript HTML JS JS JS HTML HTML Module Module Module
  • 36. UI Rendering time HTML Javascript HTML JS JS JS HTML HTML Module Module Module
  • 37. UI Rendering time HTML Javascript HTML JS JS JS HTML HTML Module Module Module JS JS JS HTML HTML Module Module Module
  • 38. UI Rendering time HTML Javascript HTML JS JS JS HTML HTML Module Module Module JS JS JS HTML HTML Module Module Module
  • 39. UI Rendering time HTML Javascript HTML JS JS JS HTML HTML Module Module Module JS JS JS HTML HTML Module Module Module JS Module JS HTML HTML Module JS Module
  • 40. Async Module Definition Mechanism for Suits where sync defining modules Non-blocking loading causes bad and dependencies parallel loading performance
  • 41. AMD: who? ● RequireJS ● curl.js ● Almond ● StealJS
  • 42. Compilation Reduce the script Check for syntax size Intellectual mistakes (minify, unify) Property (uglify)
  • 43. Compilation: who? ● Google Closure ● RequireJS ● StealJS ● YUI Compressor
  • 45. Base Library Pure JS Example VS jQuery Example