SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
SuRvIvInG RoBoTs aNd OlD BrOwSeRs bY
       SeRvEr-sIdE BaCkBoNe"
                                                    LaUrI SvAn @lAuRiSvAn
                                                    Sc5 OnLiNe @sC5




             HtMl5 eXpErTiSe aT yOuR sErViCe 	
  
HeLp! My SiNgLe PaGe ApP
   FaIlS fOr RoBoTs!
WhY dEsIgN yOuR ApP fOr
1% oR 0.1% oF YoUr tRaFfIc?
UsE a PrOxY fOr LeGaCy BrOwSeRs
                                                              Browser	
  

                      Browser	
  interfaces	
  




 Server	
  API	
     Full	
  
                     app	
  
                                          Plain	
  HTML	
  




                                     App	
  Proxy	
  
WhAt Do I GaIn?
•    Solve the Robot problem – remove double code paths
•    Speed up time to first render – bootstrap your DOM
•    Potentially solve the “legacy browser” problem
•    Ease your test automation – mocking your API/App
WhAt DoEs iT TaKe tO AcHiEvE?
•    JavaScript support (node.js)
•    Shared module loader (Require.js / Browserify)
•    Some way to emulate/abstract out DOM
•    Some shims for Browser APIs (XHR, localStorage etc…)
•    Some way to tell your app has completed rendering
QuEsTs FoR tHe HoLy GrAiL ReViSiTeD
GrAiLs: WhAt yOuR ApP MiGhT LoOk LiKe
                                           •  Some partial layering model
Application Logic & Templates
                                           •  App touches the browser APIs
  Backbone
                                              through all the layers
       jQuery

        Browser API
                                           •  Everything needs server-side
     JavaScript Runtime
                                              shims!



                      Runs on both as-is
                        Compatibility
                            Layer
                      Platform Specific
GrAiLs: PrOxY BrOwSeR (PhAnToM.Js)
             Browser                   •  Full WebKit implementation on
                                          server-side
                                       •  Runs on its own process/server
          Reverse Proxy

smart
clients
                            dumb
                            clients    •  Context sharing with Phantom.js
App Server             Proxy Browser
                                          process is tricky
                                       •  Chromium Embedded Framework
                                          & Node.js would even better?
GrAiLs: TeMpLaTe ShArInG (tHe nOrMaL wAy)
                Templates                        •  Share the templates on client
            Data Representation                     and server
Application Logic        Server Logic            •  Separate codebases for
Backbone                                            compositing the page fragments
   jQuery

  Browser API                                    •  Simple to understand
   JavaScript
    Runtime
                         Any Runtime             •  Double code paths: Double
                                                    testing, maintenance etc.
                            Runs on both as-is
                              Compatibility
                                  Layer
                            Platform Specific
GrAiLs: ShArEd ClIeNt-sErVeR Fw (DeRbY, MeTeOr)

                                          •  Full app frameworks that hide
Application Logic & Templates
                                             the DOM
     Custom Framework
                                          •  Hide client/server messaging
                                             (socket.io etc.)
                                          •  Meteor still uses PhantomJS to
     JavaScript Runtime
                                             render for robots?
                                          •  Lock-in to a certain
                                             development model
                     Runs on both as-is
                                          •  Lock-in to a certain backend
                        Compatibility
                            Layer
                      Platform Specific
GrAiLs: SeRvEr-sIdE DoM (JsDoM)
                                          •  JSDOM - Full JavaScript DOM
Application Logic & Templates
                                             implementation
  Backbone
                                          •  How about the other APIs?
       jQuery
                                          •  Browser/HTML5 APIs is huge!
    Browser API Subset
                                          •  Slow to emulate
     JavaScript Runtime




                     Runs on both as-is
                        Compatibility
                            Layer
                      Platform Specific
GrAiLs: SeRvEr-sIdE jQuErY (ChEeRiO)
                                            •  Use jQuery for compatibility
Application Logic & Templates

  Backbone
                                            •  Hide the DOM below
      jQuery / Cheerio

                                            •  Limited adaptation problem
     JavaScript Runtime                     •  Potentially faster
                                            •  Changes to Backbone needed


                     Runs on both as-is
                           Compatibility
                               Layer
                         Platform Specific
GrAiLs: AbStRaCt oUt DoM (AiRbNb / ReNdR)
                                            •  Backbone, but abstract out all
  Application Logic & Templates
                                               DOM manipulation from view
    Backbone
                                               manipulation
        Adaptation Layer
                                            •  AirBNB - Concatenate
                                               templates on server
       JavaScript Runtime                   •  No jQuery, no DOM access
                                            •  Is it the same anymore?

                       Runs on both as-is
                          Compatibility
                              Layer
                        Platform Specific
GrAiLs: CoMpArIsOn                                                 Template	
  Sharing	
  
                                                                                        Templates
   Your	
  Typical	
  App	
       Shared	
  Client-­‐Server	
  FW	
                 Data Representation

  Application Logic & Templates        Application Logic & Templates    Application Logic        Server Logic

    Backbone                                Custom Framework            Backbone

         jQuery                                                            jQuery

          Browser API                                                     Browser API

       JavaScript Runtime                   JavaScript Runtime             JavaScript            Any Runtime
                                                                            Runtime



DOM	
  Abstracted	
  out	
                    JSDOM	
                                Cheerio	
  
  Application Logic & Templates        Application Logic & Templates          Application Logic & Templates

    Backbone                             Backbone                               Backbone

        Adaptation Layer                      jQuery                                 jQuery / Cheerio

                                           Browser API Subset
                                                                                                                Runs on both as-is
                                                                                                                  Compatibility
       JavaScript Runtime                   JavaScript Runtime                      JavaScript Runtime                Layer
                                                                                                                Platform Specific
AlMoSt aLl oF oUr aPpS aRe BaCkBoNe & JqUeRy
    YoU cAn’t tEaCh oLd dOg nEw tRiCkS
BaCkBoNe-SeRvErSiDe – oUr DeSiGn PrInCiPlEs
•  We do not need to be a full browser
•  We cannot expect the world to change our way
•  API compatibility is our friend

•    Make it a polyfill, not a library or framework
•    Do not assume anything else than Backbone
•    Retain API compatibility, hide the dirty tricks if possible
•    Retain the possibility to use 3rd party JavaScript libs
•    Keep app specific changes to minimum
InTrOdUcInG BaCkBoNe-SeRvErSiDe
                             •  Run the same Backbone SPA on both
       Application              client and server with minimal extra
                                conventions
Backbone
                             •  Removes Backbone DOM depencies
 jQuery / Cheerio            •  Cheerio jQuery subset for DOM
Browser / Adaptation Layer
                                manipulation
                             •  Polyfills for Cheerio (events, ajax)
   JavaScript Runtime

                             Things you may need to change in your app:
                             •  Stick to a subset of jQuery (Cheerio)
                             •  Use a dependency manager that you can
                                run on both ends (AMD/RequireJS,
                                CommonJS/Browserify)
                             •  Implement a messaging mechanism
                                between your node.js server and your app
SeRvEr-sIdE BaCkBoNe RePlAcEmEnTs
                                              •  The classes you typically use will run
                                                 as-is
           Collection




                                    Router
Model




                                              •  The classes that touch the DOM
                           View




                                                 underneath need changes
    sync
                                              We stub out/replace a few things
                                    History
                           jQuery




    Ajax
                                              •  jQuery: Cheerio and its fake DOM
                                              •  Ajax: Replace jQuery.ajax with a 3rd
                                                 party node.js module
                        Runs on both as-is
                          Compatibility       •  History: Trim away DOM specifics
                              Layer
                        Platform Specific         (window.navigator.location etc.)
WhEn ArE We ReAdY tO SeNd tHe PaGe BaCk?
Browser / Server
                                                                            One way on how to handle
     parse path /
      pushState
                                            Inject to DOM                   the problem
Backbone App
                                                                            •  Use Backbone events for
   Router                                                                      messaging
       handle
        route
                        verify all
                         states
                                              pass the
                                               results                      •  Single point of control
   Model                             View                                      (App Singleton/Router)
        fetch
       models
                    notify            render       notify
                                                                            •  All relevant objects have an
                                                            Legend:            observable state
Server API
                                                              direct call
        serve
        JSON
                                                                event
FeAtUrE dEtEcTiOn – A MuSt HaVe?
•  Require.js is hard to get right on the both ends
     •  Conditional switches between jQuery and Cheerio needed
     •  Some client-slide libraries just won’t load
•  Typical applications use DOM and Browser APIs directly
•  Typical 3rd party libraries use DOM & Browser APIs
   extensively

à You will benefit from a feature detection library
DeMo TiMe
BaCkBoNe-SeRvErSiDe – WoRk iN PrOgReSs
•  It is still experimental, but already demonstrable
•  Contributions wanted at our GitHub at
   SC5/backbone-serverside
•  An article in Mozilla Hacks just got out
•  Some of the near-term work involves
     •    Handling feature detection (analytics, DOM events)
     •    Cross-request user state management (localStorage adapters?)
     •    Concurrency handling (currently we have single, shared DOM)
     •    Samples on robot & browser detection (express-device)
QuEsTiOnS?
LeT’s SoLvE tHe CrAwLaBiLiTy PrObLeM!


                                LaUrI SvAn
                                Software Architect, SC5 Online Ltd
                                https://github.com/laurisvan
                                @laurisvan




            HtMl5 eXpErTiSe aT yOuR sErViCe 	
  

Contenu connexe

Tendances

VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...itsatony
 
Desktop Applications with NetBeans
Desktop Applications with NetBeansDesktop Applications with NetBeans
Desktop Applications with NetBeansHuu Bang Le Phan
 
Netbeans
NetbeansNetbeans
Netbeansacosdt
 
Enhancing Spring MVC Web Applications Progressively with Spring JavaScript
Enhancing Spring MVC Web Applications Progressively with Spring JavaScriptEnhancing Spring MVC Web Applications Progressively with Spring JavaScript
Enhancing Spring MVC Web Applications Progressively with Spring JavaScriptJeremy Grelle
 
Modern JavaScript Frameworks: Angular, React & Vue.js
Modern JavaScript Frameworks: Angular, React & Vue.jsModern JavaScript Frameworks: Angular, React & Vue.js
Modern JavaScript Frameworks: Angular, React & Vue.jsJonas Bandi
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and moreYan Shi
 
HTML5DevConf 2013 (October): WebGL is a game changer!
HTML5DevConf 2013 (October): WebGL is a game changer!HTML5DevConf 2013 (October): WebGL is a game changer!
HTML5DevConf 2013 (October): WebGL is a game changer!Iker Jamardo
 
XPages Binary Output
XPages Binary OutputXPages Binary Output
XPages Binary OutputJohnFoldager
 
Optimizing HTML5 Sites with CQ5/WEM
Optimizing HTML5 Sites with CQ5/WEMOptimizing HTML5 Sites with CQ5/WEM
Optimizing HTML5 Sites with CQ5/WEMGabriel Walt
 
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...jaxconf
 

Tendances (19)

VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
 
CRUD with Polymer 2.0
CRUD with Polymer 2.0CRUD with Polymer 2.0
CRUD with Polymer 2.0
 
Desktop Applications with NetBeans
Desktop Applications with NetBeansDesktop Applications with NetBeans
Desktop Applications with NetBeans
 
Netbeans
NetbeansNetbeans
Netbeans
 
Enhancing Spring MVC Web Applications Progressively with Spring JavaScript
Enhancing Spring MVC Web Applications Progressively with Spring JavaScriptEnhancing Spring MVC Web Applications Progressively with Spring JavaScript
Enhancing Spring MVC Web Applications Progressively with Spring JavaScript
 
Javantura Zagreb 2014 - Vaadin - Peter Lehto
Javantura Zagreb 2014 - Vaadin - Peter LehtoJavantura Zagreb 2014 - Vaadin - Peter Lehto
Javantura Zagreb 2014 - Vaadin - Peter Lehto
 
Modern JavaScript Frameworks: Angular, React & Vue.js
Modern JavaScript Frameworks: Angular, React & Vue.jsModern JavaScript Frameworks: Angular, React & Vue.js
Modern JavaScript Frameworks: Angular, React & Vue.js
 
Web Components and PWA
Web Components and PWAWeb Components and PWA
Web Components and PWA
 
JavaScript-Core
JavaScript-CoreJavaScript-Core
JavaScript-Core
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Dojo (QCon 2007 Slides)
Dojo (QCon 2007 Slides)Dojo (QCon 2007 Slides)
Dojo (QCon 2007 Slides)
 
Crx 2.2 Deep-Dive
Crx 2.2 Deep-DiveCrx 2.2 Deep-Dive
Crx 2.2 Deep-Dive
 
HTML5DevConf 2013 (October): WebGL is a game changer!
HTML5DevConf 2013 (October): WebGL is a game changer!HTML5DevConf 2013 (October): WebGL is a game changer!
HTML5DevConf 2013 (October): WebGL is a game changer!
 
XPages Binary Output
XPages Binary OutputXPages Binary Output
XPages Binary Output
 
Javascript
JavascriptJavascript
Javascript
 
Netbeans IDE & Platform
Netbeans IDE & PlatformNetbeans IDE & Platform
Netbeans IDE & Platform
 
Optimizing HTML5 Sites with CQ5/WEM
Optimizing HTML5 Sites with CQ5/WEMOptimizing HTML5 Sites with CQ5/WEM
Optimizing HTML5 Sites with CQ5/WEM
 
Booting up with polymer
Booting up with polymerBooting up with polymer
Booting up with polymer
 
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
Vaadin, Rich Web Apps in Server-Side Java without Plug-ins or JavaScript: Joo...
 

Similaire à Surviving Robots and Old Browsers with Server-Side Backbones

Building single page applications
Building single page applicationsBuilding single page applications
Building single page applicationsSC5.io
 
Stealing Chromium: Embedding HTML5 with the Servo Browser Engine (LinuxCon NA...
Stealing Chromium: Embedding HTML5 with the Servo Browser Engine (LinuxCon NA...Stealing Chromium: Embedding HTML5 with the Servo Browser Engine (LinuxCon NA...
Stealing Chromium: Embedding HTML5 with the Servo Browser Engine (LinuxCon NA...Samsung Open Source Group
 
Sahi Principles and Architecture
Sahi Principles and ArchitectureSahi Principles and Architecture
Sahi Principles and ArchitectureTyto Software
 
Kann JavaScript elegant sein?
Kann JavaScript elegant sein?Kann JavaScript elegant sein?
Kann JavaScript elegant sein?jbandi
 
Building Real-World Dojo Web Applications
Building Real-World Dojo Web ApplicationsBuilding Real-World Dojo Web Applications
Building Real-World Dojo Web ApplicationsAndrew Ferrier
 
Women Who Code, Ground Floor
Women Who Code, Ground FloorWomen Who Code, Ground Floor
Women Who Code, Ground FloorKatie Weiss
 
Frameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic ReviewFrameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic Reviewnetc2012
 
Gwt cdi jaxrs_hbraun
Gwt cdi jaxrs_hbraunGwt cdi jaxrs_hbraun
Gwt cdi jaxrs_hbraunhbraun
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5David Voyles
 
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsIn Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsSpike Brehm
 
Meetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech PeopleMeetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech PeopleIT Arena
 
Gwt cdi jud_con_berlin
Gwt cdi jud_con_berlinGwt cdi jud_con_berlin
Gwt cdi jud_con_berlinhbraun
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?Balajihope
 
Isomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webIsomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webSigma Software
 
Titanium: Native Mobile Apps with Javascript
Titanium: Native Mobile Apps with Javascript Titanium: Native Mobile Apps with Javascript
Titanium: Native Mobile Apps with Javascript Leonardo Farias
 
Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012Adam Mokan
 

Similaire à Surviving Robots and Old Browsers with Server-Side Backbones (20)

Building single page applications
Building single page applicationsBuilding single page applications
Building single page applications
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
20120802 timisoara
20120802 timisoara20120802 timisoara
20120802 timisoara
 
Stealing Chromium: Embedding HTML5 with the Servo Browser Engine (LinuxCon NA...
Stealing Chromium: Embedding HTML5 with the Servo Browser Engine (LinuxCon NA...Stealing Chromium: Embedding HTML5 with the Servo Browser Engine (LinuxCon NA...
Stealing Chromium: Embedding HTML5 with the Servo Browser Engine (LinuxCon NA...
 
Rhodes
RhodesRhodes
Rhodes
 
Sahi Principles and Architecture
Sahi Principles and ArchitectureSahi Principles and Architecture
Sahi Principles and Architecture
 
Kann JavaScript elegant sein?
Kann JavaScript elegant sein?Kann JavaScript elegant sein?
Kann JavaScript elegant sein?
 
Building Real-World Dojo Web Applications
Building Real-World Dojo Web ApplicationsBuilding Real-World Dojo Web Applications
Building Real-World Dojo Web Applications
 
Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)Apache Drill (ver. 0.2)
Apache Drill (ver. 0.2)
 
Women Who Code, Ground Floor
Women Who Code, Ground FloorWomen Who Code, Ground Floor
Women Who Code, Ground Floor
 
Frameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic ReviewFrameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic Review
 
Gwt cdi jaxrs_hbraun
Gwt cdi jaxrs_hbraunGwt cdi jaxrs_hbraun
Gwt cdi jaxrs_hbraun
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
 
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript AppsIn Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
In Pursuit of the Holy Grail: Building Isomorphic JavaScript Apps
 
Meetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech PeopleMeetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech People
 
Gwt cdi jud_con_berlin
Gwt cdi jud_con_berlinGwt cdi jud_con_berlin
Gwt cdi jud_con_berlin
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 
Isomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the webIsomorphic JavaScript – future of the web
Isomorphic JavaScript – future of the web
 
Titanium: Native Mobile Apps with Javascript
Titanium: Native Mobile Apps with Javascript Titanium: Native Mobile Apps with Javascript
Titanium: Native Mobile Apps with Javascript
 
Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012Single Page Applications - Desert Code Camp 2012
Single Page Applications - Desert Code Camp 2012
 

Plus de SC5.io

AWS Machine Learning & Google Cloud Machine Learning
AWS Machine Learning & Google Cloud Machine LearningAWS Machine Learning & Google Cloud Machine Learning
AWS Machine Learning & Google Cloud Machine LearningSC5.io
 
Transfer learning with Custom Vision
Transfer learning with Custom VisionTransfer learning with Custom Vision
Transfer learning with Custom VisionSC5.io
 
Practical AI for Business: Bandit Algorithms
Practical AI for Business: Bandit AlgorithmsPractical AI for Business: Bandit Algorithms
Practical AI for Business: Bandit AlgorithmsSC5.io
 
Decision trees & random forests
Decision trees & random forestsDecision trees & random forests
Decision trees & random forestsSC5.io
 
Bandit Algorithms
Bandit AlgorithmsBandit Algorithms
Bandit AlgorithmsSC5.io
 
Machine Learning Using Cloud Services
Machine Learning Using Cloud ServicesMachine Learning Using Cloud Services
Machine Learning Using Cloud ServicesSC5.io
 
Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto UniversitySC5.io
 
Miten design-muutosjohtaminen hyödyttää yrityksiä?
Miten design-muutosjohtaminen hyödyttää yrityksiä?Miten design-muutosjohtaminen hyödyttää yrityksiä?
Miten design-muutosjohtaminen hyödyttää yrityksiä?SC5.io
 
Securing the client side web
Securing the client side webSecuring the client side web
Securing the client side webSC5.io
 
Engineering HTML5 Applications for Better Performance
Engineering HTML5 Applications for Better PerformanceEngineering HTML5 Applications for Better Performance
Engineering HTML5 Applications for Better PerformanceSC5.io
 
2013 10-02-backbone-robots-aarhus
2013 10-02-backbone-robots-aarhus2013 10-02-backbone-robots-aarhus
2013 10-02-backbone-robots-aarhusSC5.io
 
2013 10-02-html5-performance-aarhus
2013 10-02-html5-performance-aarhus2013 10-02-html5-performance-aarhus
2013 10-02-html5-performance-aarhusSC5.io
 

Plus de SC5.io (12)

AWS Machine Learning & Google Cloud Machine Learning
AWS Machine Learning & Google Cloud Machine LearningAWS Machine Learning & Google Cloud Machine Learning
AWS Machine Learning & Google Cloud Machine Learning
 
Transfer learning with Custom Vision
Transfer learning with Custom VisionTransfer learning with Custom Vision
Transfer learning with Custom Vision
 
Practical AI for Business: Bandit Algorithms
Practical AI for Business: Bandit AlgorithmsPractical AI for Business: Bandit Algorithms
Practical AI for Business: Bandit Algorithms
 
Decision trees & random forests
Decision trees & random forestsDecision trees & random forests
Decision trees & random forests
 
Bandit Algorithms
Bandit AlgorithmsBandit Algorithms
Bandit Algorithms
 
Machine Learning Using Cloud Services
Machine Learning Using Cloud ServicesMachine Learning Using Cloud Services
Machine Learning Using Cloud Services
 
Angular.js Primer in Aalto University
Angular.js Primer in Aalto UniversityAngular.js Primer in Aalto University
Angular.js Primer in Aalto University
 
Miten design-muutosjohtaminen hyödyttää yrityksiä?
Miten design-muutosjohtaminen hyödyttää yrityksiä?Miten design-muutosjohtaminen hyödyttää yrityksiä?
Miten design-muutosjohtaminen hyödyttää yrityksiä?
 
Securing the client side web
Securing the client side webSecuring the client side web
Securing the client side web
 
Engineering HTML5 Applications for Better Performance
Engineering HTML5 Applications for Better PerformanceEngineering HTML5 Applications for Better Performance
Engineering HTML5 Applications for Better Performance
 
2013 10-02-backbone-robots-aarhus
2013 10-02-backbone-robots-aarhus2013 10-02-backbone-robots-aarhus
2013 10-02-backbone-robots-aarhus
 
2013 10-02-html5-performance-aarhus
2013 10-02-html5-performance-aarhus2013 10-02-html5-performance-aarhus
2013 10-02-html5-performance-aarhus
 

Dernier

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: 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
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
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
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 

Dernier (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: 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
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
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
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 

Surviving Robots and Old Browsers with Server-Side Backbones

  • 1. SuRvIvInG RoBoTs aNd OlD BrOwSeRs bY SeRvEr-sIdE BaCkBoNe" LaUrI SvAn @lAuRiSvAn Sc5 OnLiNe @sC5 HtMl5 eXpErTiSe aT yOuR sErViCe  
  • 2. HeLp! My SiNgLe PaGe ApP FaIlS fOr RoBoTs!
  • 3. WhY dEsIgN yOuR ApP fOr 1% oR 0.1% oF YoUr tRaFfIc?
  • 4. UsE a PrOxY fOr LeGaCy BrOwSeRs Browser   Browser  interfaces   Server  API   Full   app   Plain  HTML   App  Proxy  
  • 5. WhAt Do I GaIn? •  Solve the Robot problem – remove double code paths •  Speed up time to first render – bootstrap your DOM •  Potentially solve the “legacy browser” problem •  Ease your test automation – mocking your API/App
  • 6. WhAt DoEs iT TaKe tO AcHiEvE? •  JavaScript support (node.js) •  Shared module loader (Require.js / Browserify) •  Some way to emulate/abstract out DOM •  Some shims for Browser APIs (XHR, localStorage etc…) •  Some way to tell your app has completed rendering
  • 7. QuEsTs FoR tHe HoLy GrAiL ReViSiTeD
  • 8. GrAiLs: WhAt yOuR ApP MiGhT LoOk LiKe •  Some partial layering model Application Logic & Templates •  App touches the browser APIs Backbone through all the layers jQuery Browser API •  Everything needs server-side JavaScript Runtime shims! Runs on both as-is Compatibility Layer Platform Specific
  • 9. GrAiLs: PrOxY BrOwSeR (PhAnToM.Js) Browser •  Full WebKit implementation on server-side •  Runs on its own process/server Reverse Proxy smart clients dumb clients •  Context sharing with Phantom.js App Server Proxy Browser process is tricky •  Chromium Embedded Framework & Node.js would even better?
  • 10. GrAiLs: TeMpLaTe ShArInG (tHe nOrMaL wAy) Templates •  Share the templates on client Data Representation and server Application Logic Server Logic •  Separate codebases for Backbone compositing the page fragments jQuery Browser API •  Simple to understand JavaScript Runtime Any Runtime •  Double code paths: Double testing, maintenance etc. Runs on both as-is Compatibility Layer Platform Specific
  • 11. GrAiLs: ShArEd ClIeNt-sErVeR Fw (DeRbY, MeTeOr) •  Full app frameworks that hide Application Logic & Templates the DOM Custom Framework •  Hide client/server messaging (socket.io etc.) •  Meteor still uses PhantomJS to JavaScript Runtime render for robots? •  Lock-in to a certain development model Runs on both as-is •  Lock-in to a certain backend Compatibility Layer Platform Specific
  • 12. GrAiLs: SeRvEr-sIdE DoM (JsDoM) •  JSDOM - Full JavaScript DOM Application Logic & Templates implementation Backbone •  How about the other APIs? jQuery •  Browser/HTML5 APIs is huge! Browser API Subset •  Slow to emulate JavaScript Runtime Runs on both as-is Compatibility Layer Platform Specific
  • 13. GrAiLs: SeRvEr-sIdE jQuErY (ChEeRiO) •  Use jQuery for compatibility Application Logic & Templates Backbone •  Hide the DOM below jQuery / Cheerio •  Limited adaptation problem JavaScript Runtime •  Potentially faster •  Changes to Backbone needed Runs on both as-is Compatibility Layer Platform Specific
  • 14. GrAiLs: AbStRaCt oUt DoM (AiRbNb / ReNdR) •  Backbone, but abstract out all Application Logic & Templates DOM manipulation from view Backbone manipulation Adaptation Layer •  AirBNB - Concatenate templates on server JavaScript Runtime •  No jQuery, no DOM access •  Is it the same anymore? Runs on both as-is Compatibility Layer Platform Specific
  • 15. GrAiLs: CoMpArIsOn Template  Sharing   Templates Your  Typical  App   Shared  Client-­‐Server  FW   Data Representation Application Logic & Templates Application Logic & Templates Application Logic Server Logic Backbone Custom Framework Backbone jQuery jQuery Browser API Browser API JavaScript Runtime JavaScript Runtime JavaScript Any Runtime Runtime DOM  Abstracted  out   JSDOM   Cheerio   Application Logic & Templates Application Logic & Templates Application Logic & Templates Backbone Backbone Backbone Adaptation Layer jQuery jQuery / Cheerio Browser API Subset Runs on both as-is Compatibility JavaScript Runtime JavaScript Runtime JavaScript Runtime Layer Platform Specific
  • 16. AlMoSt aLl oF oUr aPpS aRe BaCkBoNe & JqUeRy YoU cAn’t tEaCh oLd dOg nEw tRiCkS
  • 17. BaCkBoNe-SeRvErSiDe – oUr DeSiGn PrInCiPlEs •  We do not need to be a full browser •  We cannot expect the world to change our way •  API compatibility is our friend •  Make it a polyfill, not a library or framework •  Do not assume anything else than Backbone •  Retain API compatibility, hide the dirty tricks if possible •  Retain the possibility to use 3rd party JavaScript libs •  Keep app specific changes to minimum
  • 18. InTrOdUcInG BaCkBoNe-SeRvErSiDe •  Run the same Backbone SPA on both Application client and server with minimal extra conventions Backbone •  Removes Backbone DOM depencies jQuery / Cheerio •  Cheerio jQuery subset for DOM Browser / Adaptation Layer manipulation •  Polyfills for Cheerio (events, ajax) JavaScript Runtime Things you may need to change in your app: •  Stick to a subset of jQuery (Cheerio) •  Use a dependency manager that you can run on both ends (AMD/RequireJS, CommonJS/Browserify) •  Implement a messaging mechanism between your node.js server and your app
  • 19. SeRvEr-sIdE BaCkBoNe RePlAcEmEnTs •  The classes you typically use will run as-is Collection Router Model •  The classes that touch the DOM View underneath need changes sync We stub out/replace a few things History jQuery Ajax •  jQuery: Cheerio and its fake DOM •  Ajax: Replace jQuery.ajax with a 3rd party node.js module Runs on both as-is Compatibility •  History: Trim away DOM specifics Layer Platform Specific (window.navigator.location etc.)
  • 20. WhEn ArE We ReAdY tO SeNd tHe PaGe BaCk? Browser / Server One way on how to handle parse path / pushState Inject to DOM the problem Backbone App •  Use Backbone events for Router messaging handle route verify all states pass the results •  Single point of control Model View (App Singleton/Router) fetch models notify render notify •  All relevant objects have an Legend: observable state Server API direct call serve JSON event
  • 21. FeAtUrE dEtEcTiOn – A MuSt HaVe? •  Require.js is hard to get right on the both ends •  Conditional switches between jQuery and Cheerio needed •  Some client-slide libraries just won’t load •  Typical applications use DOM and Browser APIs directly •  Typical 3rd party libraries use DOM & Browser APIs extensively à You will benefit from a feature detection library
  • 23. BaCkBoNe-SeRvErSiDe – WoRk iN PrOgReSs •  It is still experimental, but already demonstrable •  Contributions wanted at our GitHub at SC5/backbone-serverside •  An article in Mozilla Hacks just got out •  Some of the near-term work involves •  Handling feature detection (analytics, DOM events) •  Cross-request user state management (localStorage adapters?) •  Concurrency handling (currently we have single, shared DOM) •  Samples on robot & browser detection (express-device)
  • 25. LeT’s SoLvE tHe CrAwLaBiLiTy PrObLeM! LaUrI SvAn Software Architect, SC5 Online Ltd https://github.com/laurisvan @laurisvan HtMl5 eXpErTiSe aT yOuR sErViCe