SlideShare a Scribd company logo
Spine.js & creating
non-blocking user interfaces
       Hjortur Hilmarsson
          @hjortureh
Agenda

● Why MVC ?
● Spine.js
● Async UIs
● Tips & Tricks
● QnA
Javascript MVC
Why MVC ?



      “I wan't better UX”
                   The user
Why MVC ?



  “Can it be done in HTML5 ?”
                       The Boss
Why MVC ?


 “So much Javascript, no structure
    & always solving the same
           problems”
                          The
                          Developer
Common problems

● Structure
● Events
● Routing
● RESTful sync
● Local storage
MVC Frameworks
 ● Backbone.js
 ● Ember.js (SproutCore 2.0)
 ● Spine.js
 ● JavaScriptMVC
 ● Sammy.js
 ● YUILibrary
 ● KnockoutJS (MVVM)
 ● Knockback
 ● AngularJS
 ● Broke.js
 ● Fidel.js
 ● ExtJS
                     Source: https://github.com/addyosmani/todomvc
Backbone & Spine
 Lightweight MVC frameworks
Spine.js

● Inspire by Backbone.js
● Written in Coffee Script
● Async UIs
● Very light ( 2k )
● Includes
    ○ Classes
    ○ Models
    ○ Controllers
    ○ Routes
    ○ Events
Backbone vs Spine
    Views vs. Controllers
  Model/Collection vs. Model
Backbone model

var ContactModel = Backbone.Model.extend({});

var ContactCollection = Backbone.Collection.extend({
model: ContactModel,
url: "contacts"
});


// Usage

var contacts = new ContactCollection();
var contact = new ContactModel(
{ name: "Sven Svensson", email: "sven@svensson.se" }
);

contacts.create( contact );
Spine.js model

var ContactModel = Spine.Model.sub();
ContactModel.configure("Contact", "name", "email");
ContactModel.extend( Spine.Model.Ajax );


// Usage

var contact = new ContactModel(
   { name: "Sven Svensson", email: "sven@svensson.se" }
);

contact.save();
Spine.js model in Coffee Script

class ContactModel extends Spine.Model
 @configure "Contact", "name", "email"
 @extend "Contact", "name", "email"


// Usage

contact = new ContactModel(
  name: "Sven Svensson", email: "sven@svensson.se"
)

contact.save()
Spine js & creating non blocking user interfaces
Backbone view
var ContactView = Backbone.View.extend({

events: { "click li": "openContact" },

initialize: function() {
contacts.bind( "reset", reset, this );
contacts.fetch();
},
reset: function() {
            this.contactList = this.$("#contact-list");
            ...
      },

      openContact: function() { ... },

});

// Usage
new ContactView({ el: $("#view").get(0) });
Spine.js controller
var ContactView = Spine.Controller.create({

events: { "click li": "openContact" },

elements: { "#contact-list": "contactList" },

init: function() {
ContactModel.bind( "refresh", refresh );
ContactModel.fetch();
},

openContact: function() { ... },
refresh: function() { ... },

});


// Usage
new ContactView({ el: $("#view") });
Async UIs
Async UIs 

          Backbone              Spine

     save()            save()

     validate()        validate()

     ajax()            save callback()

     save callback()   ajax()
Contact Us - Examples
Does not work everywhere

 ● Transaction
 ● Login
 ● Need for server-side validation

Notes:
 ● Spine.js also has ajaxSuccess & ajaxError events
 ● Works for CUD, not Read
Don't believe me ?

■ Amazon: 100 ms of extra load time caused a 1% drop in
  sales (source: Greg Linden, Amazon).
■ Google: 500 ms of extra load time caused 20% fewer
  searches (source: Marrissa Mayer, Google).
■ Yahoo!: 400 ms of extra load time caused a 5–9% increase
  in the number of people who clicked “back” before the page
  even loaded (source: Nicole Sullivan, Yahoo!).
Spine js & creating non blocking user interfaces
What about read ? - Examples
Bonus

● Read Docs & Code
● Check TodoMVC
● Use Jasmine / Sinon.js for testing
QnA
Thanks!

@hjortureh

More Related Content

PDF
Transakcyjność w django
PDF
Lesson 09
PPTX
Introduction à AngularJS
PDF
Lesson 09
PPTX
Mobile architecture problems and solutions.
PPTX
Top 10 Mistakes AngularJS Developers Make
PDF
Vue.js for beginners
PDF
Introduction to AJAX In WordPress
Transakcyjność w django
Lesson 09
Introduction à AngularJS
Lesson 09
Mobile architecture problems and solutions.
Top 10 Mistakes AngularJS Developers Make
Vue.js for beginners
Introduction to AJAX In WordPress

What's hot (20)

PPTX
Angularjs Anti-patterns
PDF
Mini-Training: AngularJS
PDF
Angularjs in mobile app
PPTX
Angular js tutorial slides
PPTX
Angular js for beginners
PPTX
Vue js for beginner
PDF
Vue.js
PDF
AngularJS - What is it & Why is it awesome ? (with demos)
PDF
Nuxt.JS Introdruction
PPTX
AngularJS in 60ish Minutes
PPTX
Node.js with WebMatrix
PDF
Angular.js опыт использования, проблемы и решения
PDF
Unobtrusive JavaScript
PDF
Service worker - Offline Web
PPTX
Getting started with node.js
PDF
PDF
VueJS: The Simple Revolution
PDF
An introduction to knockout.js
PPTX
Windows 8 for Web Developers
PPTX
Angularjs Performance
Angularjs Anti-patterns
Mini-Training: AngularJS
Angularjs in mobile app
Angular js tutorial slides
Angular js for beginners
Vue js for beginner
Vue.js
AngularJS - What is it & Why is it awesome ? (with demos)
Nuxt.JS Introdruction
AngularJS in 60ish Minutes
Node.js with WebMatrix
Angular.js опыт использования, проблемы и решения
Unobtrusive JavaScript
Service worker - Offline Web
Getting started with node.js
VueJS: The Simple Revolution
An introduction to knockout.js
Windows 8 for Web Developers
Angularjs Performance
Ad

Similar to Spine js & creating non blocking user interfaces (20)

ODP
Javascript frameworks: Backbone.js
PPT
AngularJS and SPA
PDF
Introduction to AngularJS For WordPress Developers
PDF
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
PPTX
Intro to AngularJs
PDF
Introduction of angular js
PPT
Backbone js
PPTX
MV* presentation frameworks in Javascript: en garde, pret, allez!
PPTX
jquery summit presentation for large scale javascript applications
PPTX
Training On Angular Js
PDF
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
PPTX
Angular js
PPT
MEAN - Notes from the field (Full-Stack Development with Javascript)
PDF
AngularJS Workshop
PPT
ASP.NET MVC Presentation
PDF
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
PPTX
Practical AngularJS
PPTX
Asp.Net MVC Intro
PPTX
MVC & backbone.js
PDF
Angular pres
Javascript frameworks: Backbone.js
AngularJS and SPA
Introduction to AngularJS For WordPress Developers
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
Intro to AngularJs
Introduction of angular js
Backbone js
MV* presentation frameworks in Javascript: en garde, pret, allez!
jquery summit presentation for large scale javascript applications
Training On Angular Js
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Angular js
MEAN - Notes from the field (Full-Stack Development with Javascript)
AngularJS Workshop
ASP.NET MVC Presentation
JSMVCOMFG - To sternly look at JavaScript MVC and Templating Frameworks
Practical AngularJS
Asp.Net MVC Intro
MVC & backbone.js
Angular pres
Ad

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation theory and applications.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Diabetes mellitus diagnosis method based random forest with bat algorithm
Programs and apps: productivity, graphics, security and other tools
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation theory and applications.pdf
Review of recent advances in non-invasive hemoglobin estimation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
sap open course for s4hana steps from ECC to s4
20250228 LYD VKU AI Blended-Learning.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Mobile App Security Testing_ A Comprehensive Guide.pdf
Approach and Philosophy of On baking technology
Chapter 3 Spatial Domain Image Processing.pdf
Network Security Unit 5.pdf for BCA BBA.
MYSQL Presentation for SQL database connectivity
Building Integrated photovoltaic BIPV_UPV.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation

Spine js & creating non blocking user interfaces

  • 1. Spine.js & creating non-blocking user interfaces Hjortur Hilmarsson @hjortureh
  • 2. Agenda ● Why MVC ? ● Spine.js ● Async UIs ● Tips & Tricks ● QnA
  • 4. Why MVC ? “I wan't better UX” The user
  • 5. Why MVC ? “Can it be done in HTML5 ?” The Boss
  • 6. Why MVC ? “So much Javascript, no structure & always solving the same problems” The Developer
  • 7. Common problems ● Structure ● Events ● Routing ● RESTful sync ● Local storage
  • 8. MVC Frameworks ● Backbone.js ● Ember.js (SproutCore 2.0) ● Spine.js ● JavaScriptMVC ● Sammy.js ● YUILibrary ● KnockoutJS (MVVM) ● Knockback ● AngularJS ● Broke.js ● Fidel.js ● ExtJS Source: https://github.com/addyosmani/todomvc
  • 9. Backbone & Spine Lightweight MVC frameworks
  • 10. Spine.js ● Inspire by Backbone.js ● Written in Coffee Script ● Async UIs ● Very light ( 2k ) ● Includes ○ Classes ○ Models ○ Controllers ○ Routes ○ Events
  • 11. Backbone vs Spine Views vs. Controllers Model/Collection vs. Model
  • 12. Backbone model var ContactModel = Backbone.Model.extend({}); var ContactCollection = Backbone.Collection.extend({ model: ContactModel, url: "contacts" }); // Usage var contacts = new ContactCollection(); var contact = new ContactModel( { name: "Sven Svensson", email: "sven@svensson.se" } ); contacts.create( contact );
  • 13. Spine.js model var ContactModel = Spine.Model.sub(); ContactModel.configure("Contact", "name", "email"); ContactModel.extend( Spine.Model.Ajax ); // Usage var contact = new ContactModel( { name: "Sven Svensson", email: "sven@svensson.se" } ); contact.save();
  • 14. Spine.js model in Coffee Script class ContactModel extends Spine.Model @configure "Contact", "name", "email" @extend "Contact", "name", "email" // Usage contact = new ContactModel( name: "Sven Svensson", email: "sven@svensson.se" ) contact.save()
  • 16. Backbone view var ContactView = Backbone.View.extend({ events: { "click li": "openContact" }, initialize: function() { contacts.bind( "reset", reset, this ); contacts.fetch(); }, reset: function() { this.contactList = this.$("#contact-list"); ... }, openContact: function() { ... }, }); // Usage new ContactView({ el: $("#view").get(0) });
  • 17. Spine.js controller var ContactView = Spine.Controller.create({ events: { "click li": "openContact" }, elements: { "#contact-list": "contactList" }, init: function() { ContactModel.bind( "refresh", refresh ); ContactModel.fetch(); }, openContact: function() { ... }, refresh: function() { ... }, }); // Usage new ContactView({ el: $("#view") });
  • 19. Async UIs  Backbone Spine save() save() validate() validate() ajax() save callback() save callback() ajax()
  • 20. Contact Us - Examples
  • 21. Does not work everywhere ● Transaction ● Login ● Need for server-side validation Notes: ● Spine.js also has ajaxSuccess & ajaxError events ● Works for CUD, not Read
  • 22. Don't believe me ? ■ Amazon: 100 ms of extra load time caused a 1% drop in sales (source: Greg Linden, Amazon). ■ Google: 500 ms of extra load time caused 20% fewer searches (source: Marrissa Mayer, Google). ■ Yahoo!: 400 ms of extra load time caused a 5–9% increase in the number of people who clicked “back” before the page even loaded (source: Nicole Sullivan, Yahoo!).
  • 24. What about read ? - Examples
  • 25. Bonus ● Read Docs & Code ● Check TodoMVC ● Use Jasmine / Sinon.js for testing
  • 26. QnA