SlideShare a Scribd company logo
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

More Related Content

What's hot

안드로이드 데이터 바인딩
안드로이드 데이터 바인딩안드로이드 데이터 바인딩
안드로이드 데이터 바인딩
GDG Korea
 
Graphiti and GMF Compared
Graphiti and GMF ComparedGraphiti and GMF Compared
Graphiti and GMF Comparedkoentsje
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Iván Fernández Perea
 
01 Introduction - JavaScript Development
01 Introduction - JavaScript Development01 Introduction - JavaScript Development
01 Introduction - JavaScript DevelopmentTommy Vercety
 
Week 8
Week 8Week 8
Week 8
A VD
 
javascript examples
javascript examplesjavascript examples
javascript examples
Egerton University
 
Javascript Module Patterns
Javascript Module PatternsJavascript Module Patterns
Javascript Module Patterns
Nicholas Jansma
 
Patterns In-Javascript
Patterns In-JavascriptPatterns In-Javascript
Patterns In-Javascript
Mindfire Solutions
 
MVC pattern for widgets
MVC pattern for widgetsMVC pattern for widgets
MVC pattern for widgets
Behnam 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 #1
Paras Mendiratta
 
Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"
Fwdays
 
Part 2
Part 2Part 2
Part 2
A VD
 
Dynamic Groovy Edges
Dynamic Groovy EdgesDynamic Groovy Edges
Dynamic Groovy Edges
Jimmy Ray
 
Large-Scale JavaScript Development
Large-Scale JavaScript DevelopmentLarge-Scale JavaScript Development
Large-Scale JavaScript Development
Addy 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/09
Daniel Bryant
 
Knockout js session
Knockout js sessionKnockout js session
Knockout js session
Ravinder Mahajan
 
Jquery
JqueryJquery
JavaScript Modules in Practice
JavaScript Modules in PracticeJavaScript Modules in Practice
JavaScript Modules in Practice
Maghdebura
 

What's hot (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
 

Similar to JS Single-Page Web App Essentials

Web 2.0
Web 2.0Web 2.0
Web 2.0
Muhammad Nasr
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVC
Acquisio
 
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
codeinmotion
 
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
 
BackboneJS + ReactJS
BackboneJS + ReactJSBackboneJS + ReactJS
BackboneJS + ReactJS
Skanda Shastry
 
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's
Antônio Roberto Silva
 
Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
Bert 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 Institute
Ravi Bhadauria
 
Heroku pop-behind-the-sense
Heroku pop-behind-the-senseHeroku pop-behind-the-sense
Heroku pop-behind-the-sense
Ben Lin
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introduction
Commit 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, 2009
ken.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 version
Sabino 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
 

Similar to JS Single-Page Web App Essentials (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
 

More from Sergey Bolshchikov

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

More from 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
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 

JS Single-Page Web App Essentials

  • 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