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
Ad

Recommended

Transakcyjność w django
Transakcyjność w django
Marcin Baran
 
Lesson 09
Lesson 09
Gene Babon
 
Introduction à AngularJS
Introduction à AngularJS
Nicolas PENNEC
 
Lesson 09
Lesson 09
Gene Babon
 
Mobile architecture problems and solutions.
Mobile architecture problems and solutions.
PiXeL16
 
Top 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers Make
Mark Meyer
 
Vue.js for beginners
Vue.js for beginners
Julio Bitencourt
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPress
Caldera Labs
 
Angularjs Anti-patterns
Angularjs Anti-patterns
Steven Lambert
 
Mini-Training: AngularJS
Mini-Training: AngularJS
Betclic Everest Group Tech Team
 
Angularjs in mobile app
Angularjs in mobile app
Yvonne Yu
 
Angular js tutorial slides
Angular js tutorial slides
samhelman
 
Angular js for beginners
Angular js for beginners
Munir Hoque
 
Vue js for beginner
Vue js for beginner
Chandrasekar G
 
Vue.js
Vue.js
BADR
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
Gary Arora
 
Nuxt.JS Introdruction
Nuxt.JS Introdruction
David Ličen
 
AngularJS in 60ish Minutes
AngularJS in 60ish Minutes
Dan Wahlin
 
Node.js with WebMatrix
Node.js with WebMatrix
Milindu Sanoj Kumarage
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решения
Olga Lavrentieva
 
Unobtrusive JavaScript
Unobtrusive JavaScript
Vitaly Baum
 
Service worker - Offline Web
Service worker - Offline Web
Bruno Oliveira
 
Getting started with node.js
Getting started with node.js
Mudassar Ali Sahil
 
Webpack
Webpack
Sofian Hadiwijaya
 
VueJS: The Simple Revolution
VueJS: The Simple Revolution
Rafael Casuso Romate
 
An introduction to knockout.js
An introduction to knockout.js
Emanuele DelBono
 
Windows 8 for Web Developers
Windows 8 for Web Developers
Gustaf Nilsson Kotte
 
Angularjs Performance
Angularjs Performance
Steven Lambert
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
Hjörtur Hilmarsson
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
Soós Gábor
 

More Related Content

What's hot (20)

Angularjs Anti-patterns
Angularjs Anti-patterns
Steven Lambert
 
Mini-Training: AngularJS
Mini-Training: AngularJS
Betclic Everest Group Tech Team
 
Angularjs in mobile app
Angularjs in mobile app
Yvonne Yu
 
Angular js tutorial slides
Angular js tutorial slides
samhelman
 
Angular js for beginners
Angular js for beginners
Munir Hoque
 
Vue js for beginner
Vue js for beginner
Chandrasekar G
 
Vue.js
Vue.js
BADR
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
Gary Arora
 
Nuxt.JS Introdruction
Nuxt.JS Introdruction
David Ličen
 
AngularJS in 60ish Minutes
AngularJS in 60ish Minutes
Dan Wahlin
 
Node.js with WebMatrix
Node.js with WebMatrix
Milindu Sanoj Kumarage
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решения
Olga Lavrentieva
 
Unobtrusive JavaScript
Unobtrusive JavaScript
Vitaly Baum
 
Service worker - Offline Web
Service worker - Offline Web
Bruno Oliveira
 
Getting started with node.js
Getting started with node.js
Mudassar Ali Sahil
 
Webpack
Webpack
Sofian Hadiwijaya
 
VueJS: The Simple Revolution
VueJS: The Simple Revolution
Rafael Casuso Romate
 
An introduction to knockout.js
An introduction to knockout.js
Emanuele DelBono
 
Windows 8 for Web Developers
Windows 8 for Web Developers
Gustaf Nilsson Kotte
 
Angularjs Performance
Angularjs Performance
Steven Lambert
 
Angularjs Anti-patterns
Angularjs Anti-patterns
Steven Lambert
 
Angularjs in mobile app
Angularjs in mobile app
Yvonne Yu
 
Angular js tutorial slides
Angular js tutorial slides
samhelman
 
Angular js for beginners
Angular js for beginners
Munir Hoque
 
Vue.js
Vue.js
BADR
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
Gary Arora
 
Nuxt.JS Introdruction
Nuxt.JS Introdruction
David Ličen
 
AngularJS in 60ish Minutes
AngularJS in 60ish Minutes
Dan Wahlin
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решения
Olga Lavrentieva
 
Unobtrusive JavaScript
Unobtrusive JavaScript
Vitaly Baum
 
Service worker - Offline Web
Service worker - Offline Web
Bruno Oliveira
 
An introduction to knockout.js
An introduction to knockout.js
Emanuele DelBono
 

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

Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
Hjörtur Hilmarsson
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
Soós Gábor
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
Alive Kuo
 
Spine.js
Spine.js
wearefractal
 
Backbone
Backbone
Sayed Ahmed
 
Javascript for Wep Apps
Javascript for Wep Apps
Michael Puckett
 
Viking academy backbone.js
Viking academy backbone.js
Bert Wijnants
 
Backbone.js
Backbone.js
VO Tho
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSockets
Andrei Sebastian Cîmpean
 
MVC & backbone.js
MVC & backbone.js
Mohammed Arif
 
Drupal Backbone.js in the Frontend
Drupal Backbone.js in the Frontend
David Corbacho Román
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
Single Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.Web
Chris Canal
 
AngularJS UTOSC
AngularJS UTOSC
roboncode
 
Real World Single Page App - A Knockout Case Study
Real World Single Page App - A Knockout Case Study
housecor
 
Intro to Backbone.js by Azat Mardanov for General Assembly
Intro to Backbone.js by Azat Mardanov for General Assembly
Azat Mardanov
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!
Roberto Messora
 
Planbox Backbone MVC
Planbox Backbone MVC
Acquisio
 
Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a time
Einar Ingebrigtsen
 
Developing Backbonejs Applications Early Release Addy Osmani
Developing Backbonejs Applications Early Release Addy Osmani
littelenkali
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
Hjörtur Hilmarsson
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
Soós Gábor
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
Alive Kuo
 
Viking academy backbone.js
Viking academy backbone.js
Bert Wijnants
 
Backbone.js
Backbone.js
VO Tho
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSockets
Andrei Sebastian Cîmpean
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
Single Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.Web
Chris Canal
 
AngularJS UTOSC
AngularJS UTOSC
roboncode
 
Real World Single Page App - A Knockout Case Study
Real World Single Page App - A Knockout Case Study
housecor
 
Intro to Backbone.js by Azat Mardanov for General Assembly
Intro to Backbone.js by Azat Mardanov for General Assembly
Azat Mardanov
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!
Roberto Messora
 
Planbox Backbone MVC
Planbox Backbone MVC
Acquisio
 
Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a time
Einar Ingebrigtsen
 
Developing Backbonejs Applications Early Release Addy Osmani
Developing Backbonejs Applications Early Release Addy Osmani
littelenkali
 
Ad

Recently uploaded (20)

AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
The Future of Product Management in AI ERA.pdf
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Mastering AI Workflows with FME by Mark Döring
Mastering AI Workflows with FME by Mark Döring
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
The Future of Product Management in AI ERA.pdf
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
Ad

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: "[email protected]" } ); 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: "[email protected]" } ); 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: "[email protected]" ) 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