SlideShare ist ein Scribd-Unternehmen logo
1 von 64
Sexy.js
Dave Furfero
UI Engineer, MLB.com
Sexy.js
          Slideshow
 http://www.slideshare.net/furf
Sexy.js
A lightweight JavaScript library which provides enhanced
Sequential Ajax (Sajax) functionality and a sleek facade to
jQuery’s native Ajax methods.
Sexy.js
 Facilitates combination and manipulation of data from
 multiple sources
 Speeds loading of scripts, stylesheets, and data using
 parallel asynchronous HTTP requests
Ugly.js
$.getJSON('articles.json', function (articles) {
 $.getJSON('comments.json', function (comments) {
   $.getJSON('ratings.json', function (ratings) {

     $.each(comments, function (i, comment) {
       articles[comment.articleId].comments.push(comment);
     });

     $.each(ratings, function (i, rating) {
       articles[rating.articleId].rating = rating;
     });

    });
  });
});
Sexy.js
Sexy
 .json('articles.json')

 .json('comments.json', function (comments, status, articles) {
   $.each(comments, function (i, comment) {
     articles[comment.articleId].comments.push(comment);
   });
   return articles;
 })

 .json('ratings.json', function (ratings, status, articles) {
   $.each(ratings, function (i, rating) {
     articles[rating.articleId].rating = rating;
   });
 });
Ugly.js
<script src="/js/jquery.template.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/comments.css" type="text/css"/>

<script type="text/javascript">

$.get('comments.tpl', function (tpl) {
  $.getJSON('comments.json', function (data) {
    $.template(tpl, data).appendTo('#comments');
  });
});

</script>
Sexy.js
<script type="text/javascript">


Sexy
 .js('jquery.template.min.js')
 .css('comments.css')
 .text('comments.tpl')
 .json('comments.json', function (data, status, tpl) {
   $.template(tpl, data).appendTo('#comments');
 });

</script>
Sexy.js
Enhanced AJAX Functionality
Sequential Ajax (Sajax)
 Simultaneous request/sequential response Ajax
 Each successive callback receives the return value of
 the previous callback as an additional argument
Sexy.js
Expressive, Chainable API
Sexy.js API
Core Methods
    html (url, callback)
    json (url, callback)
   jsonp (url, callback)
  script/js (url, callback)
  style/css (url, callback)
    text (url, callback)
    xml (url, callback)
Sexy.js API
Core Methods
    html (url, callback)        html (settings)
    json (url, callback)        json (settings)
   jsonp (url, callback)       jsonp (settings)
  script/js (url, callback)   script/js (settings)
  style/css (url, callback)   style/css (settings)
    text (url, callback)        text (settings)
    xml (url, callback)         xml (settings)
Sexy.js API
callback (data, status, previous)


 Each callback receives three arguments:
   data
   status
   previous - the return value of the previous callback
   (considering a fourth) next or this
Sexy.js API
Additional Methods
 setup (settings)
     Similar to jQuery.ajaxSetup, but limited to
     subsequent calls of a Sexy instance
     Can be unset with setup()
 bundle (url1, url2, ..., callback)
     Client-side JavaScript packaging
     Multiple file, single <script> injection
     Sequence is preserved
Using Sexy.js
Sexy
Using Sexy.js
Loading JavaScripts
Sexy
 .js('jquery.template.min.js')
Using Sexy.js
Loading Stylesheets (local only)
Sexy
 .js('jquery.template.min.js')
 .css('comments.css')
Using Sexy.js
Loading Stylesheets (local only)
Sexy
 .js('jquery.template.min.js')
 .css('comments.css')
Using Sexy.js
Loading Data
Sexy
 .js('jquery.template.min.js')
 .css('comments.css')
 .text('comments.tpl', function (data) {
   return data;
 })
Using Sexy.js
Loading Data
Sexy
 .js('jquery.template.min.js')
 .css('comments.css')
 .text('comments.tpl', function (data) {
   return data;
 })
 .json('comments.json', function (data, status, tpl) {
   $.template(tpl, data).appendTo('#comments');
 });
Using Sexy.js
Custom Ajax Settings
Sexy
 .js('jquery.template.min.js')
 .css('comments.css')
 .text('comments.tpl', function (data) {
   return data;
 })
 .json({
   url: 'comments.json',
   data: {
     article_id: 123,
   },
   success: function (data, status, tpl) {
     $.template(tpl, data).appendTo('#comments');
   }
 });
Using Sexy.js
Passing Data with Callbacks
Sexy
 .js('jquery.template.min.js')
 .css('comments.css')
 .text('comments.tpl', function (data) {
   return data;
 })
 .json('comments.json?article_id=123', function (data, status, tpl) {
   $.template(tpl, data).appendTo('#comments');
 });
Using Sexy.js
Implicit Callbacks
Sexy
 .js('jquery.template.min.js')
 .css('comments.css')
 .text('comments.tpl', function (data) {
   return data;
 })
 .json('comments.json?article_id=123', function (data, status, tpl) {
   $.template(tpl, data).appendTo('#comments');
 });
Using Sexy.js
Implicit Callbacks
Sexy
 .js('jquery.template.min.js')
 .css('comments.css')
 .text('comments.tpl', function (data) {
   return data;
 })
 .json('comments.json?article_id=123', function (data, status, tpl) {
   $.template(tpl, data).appendTo('#comments');
 });
Using Sexy.js
Implicit Callbacks, Non-Data Types
Sexy
 .css('comments.css')
 .text('comments.tpl')
 .js('jquery.template.min.js', function (data, status, previous) {
   return previous;
 })
 .json('comments.json?article_id=123', function (data, status, tpl) {
   $.template(tpl, data).appendTo('#comments');
 });
Using Sexy.js
Implicit Callbacks, Non-Data Types
Sexy
 .css('comments.css')
 .text('comments.tpl')
 .js('jquery.template.min.js')
 .json('comments.json?article_id=123', function (data, status, tpl) {
   $.template(tpl, data).appendTo('#comments');
 });
Using Sexy.js
Configuring Sexy.js
Sexy
 .setup({ cache: true })
 .js('jquery.template.min.js')
 .css('comments.css')
 .text('comments.tpl')
 .json('comments.json', function (data, status, tpl) {
   $.template(tpl, data).appendTo('#comments');
 });
Using Sexy.js
Configuring Sexy.js
Sexy({
  cache: true
})
  .js('jquery.template.min.js')
  .css('comments.css')
  .text('comments.tpl')
  .json('comments.json', function (data, status, tpl) {
    $.template(tpl, data).appendTo('#comments');
  });
Using Sexy.js
Configuring Sexy.js
Sexy({
  cache: true
})
  .js('jquery.template.min.js')
  .css('comments.css')
  .text('comments.tpl')
  .setup({ cache: false })
  .json('comments.json', function (data, status, tpl) {
    $.template(tpl, data).appendTo('#comments');
  });
Using Sexy.js
Bundling JavaScripts
Sexy
 .bundle(
   '/js/bam.js',
   ‘/js/bam.datagrid.js',
   ‘/js/bam.stats.js',
   ‘/js/bam.stats.widget.js',
   ‘/js/bam.stats.widget.leagueSelector.js',
   ‘/js/bam.stats.app.js',
   ‘/js/bam.stats.app.sortablePlayerList.js'
 );
Using Sexy.js
Bundling JavaScripts
Sexy
 .bundle(
   '/js/bam.js',
   ‘/js/bam.datagrid.js',
   ‘/js/bam.stats.js',
   ‘/js/bam.stats.widget.js',
   ‘/js/bam.stats.widget.leagueSelector.js',
   ‘/js/bam.stats.app.js',
   ‘/js/bam.stats.app.sortablePlayerList.js',

   function (src) {
     SortablePlayerList.init();
   }
 );
Known Issues

Unable to detect error events for remote requests
  jsonp (remoteUrl)
  script (remoteUrl)
  style (remoteUrl)*
*style (remoteUrl) will actually fire success event even if
load was unsuccessful (ie. 404)
Sexy.js
 Enhanced Ajax functionality
 Expressive, chainable API
 Lightweight (1.3KB compressed)
Thanks!
Slideshow: http://www.slideshare.net/furf
URL: http://sexyjs.com
Demo: http://sexyjs.com/demos/comments
Download: http:github.com/furf/Sexy
Twitter: @sexyjs
E-mail: furf@furf.com
But wait... there’s more!
Sexy is the new Sexy
Sexy() == new Sexy()
function Sexy (cfg) {

    // Allow instantiation without new keyword

    if (!(this instanceof Sexy)) {
      return new Sexy(cfg);
    }

    this.cfgs = [];
    this.setup(cfg);
    this.evt = $(this);
}
Take it off... take it all off!
Sexy.method(url) == (new Sexy()).method(url)
// Alias instance methods as static methods of constructor

$.each(Sexy.prototype, function (name, method) {
  Sexy[name] = function () {
    return method.apply(new Sexy(), arguments);
  };
});

Weitere ähnliche Inhalte

Was ist angesagt?

JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JSFestUA
 
Coffeescript - what's good
Coffeescript - what's goodCoffeescript - what's good
Coffeescript - what's goodJeongHun Byeon
 
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...allilevine
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax pluginsInbal Geffen
 
Анатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to zАнатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to zLEDC 2016
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery PresentationSony Jain
 
JQuery New Evolution
JQuery New EvolutionJQuery New Evolution
JQuery New EvolutionAllan Huang
 
AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)Brian Swartzfager
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Luka Zakrajšek
 
Data20161007
Data20161007Data20161007
Data20161007capegmail
 
Testing your javascript code with jasmine
Testing your javascript code with jasmineTesting your javascript code with jasmine
Testing your javascript code with jasmineRubyc Slides
 
The next step, part 2
The next step, part 2The next step, part 2
The next step, part 2Pat Cavit
 
Drupal & javascript
Drupal & javascriptDrupal & javascript
Drupal & javascriptAlmog Baku
 
AngularJS - $http & $resource Services
AngularJS - $http & $resource ServicesAngularJS - $http & $resource Services
AngularJS - $http & $resource ServicesEyal Vardi
 
Building Smart Async Functions For Mobile
Building Smart Async Functions For MobileBuilding Smart Async Functions For Mobile
Building Smart Async Functions For MobileGlan Thomas
 

Was ist angesagt? (20)

JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
JS Fest 2019. Glenn Reyes. With great power comes great React hooks!
 
Coffeescript - what's good
Coffeescript - what's goodCoffeescript - what's good
Coffeescript - what's good
 
Mocking Demystified
Mocking DemystifiedMocking Demystified
Mocking Demystified
 
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
 
Jqeury ajax plugins
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax plugins
 
Анатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to zАнатолий Поляков - Drupal.ajax framework from a to z
Анатолий Поляков - Drupal.ajax framework from a to z
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
 
JQuery New Evolution
JQuery New EvolutionJQuery New Evolution
JQuery New Evolution
 
AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)
 
Data20161007
Data20161007Data20161007
Data20161007
 
Testing your javascript code with jasmine
Testing your javascript code with jasmineTesting your javascript code with jasmine
Testing your javascript code with jasmine
 
The next step, part 2
The next step, part 2The next step, part 2
The next step, part 2
 
J query training
J query trainingJ query training
J query training
 
Jquery examples
Jquery examplesJquery examples
Jquery examples
 
Grails UI Primer
Grails UI PrimerGrails UI Primer
Grails UI Primer
 
Drupal & javascript
Drupal & javascriptDrupal & javascript
Drupal & javascript
 
AngularJS - $http & $resource Services
AngularJS - $http & $resource ServicesAngularJS - $http & $resource Services
AngularJS - $http & $resource Services
 
Building Smart Async Functions For Mobile
Building Smart Async Functions For MobileBuilding Smart Async Functions For Mobile
Building Smart Async Functions For Mobile
 
Pengenalan blaast platform sdk
Pengenalan blaast platform sdkPengenalan blaast platform sdk
Pengenalan blaast platform sdk
 

Andere mochten auch

promocion 2009 oscar alfaro
promocion 2009 oscar alfaropromocion 2009 oscar alfaro
promocion 2009 oscar alfarojuan carlos
 
Cara menggunakan mailing list di office 2007
Cara menggunakan mailing list di office 2007Cara menggunakan mailing list di office 2007
Cara menggunakan mailing list di office 2007teknisi7
 
Wound construction For Cataract Surgery
Wound construction For Cataract SurgeryWound construction For Cataract Surgery
Wound construction For Cataract SurgeryDevin Prabhakar
 
Capacitación en salud ocular básica y sus derechos
Capacitación en salud ocular básica y sus derechosCapacitación en salud ocular básica y sus derechos
Capacitación en salud ocular básica y sus derechosJuan Rodrigo Tuesta-Nole
 
Dossier de Oftalmologia
Dossier de OftalmologiaDossier de Oftalmologia
Dossier de OftalmologiaCDyTE
 
Cirugía de las cataratas
Cirugía de las cataratasCirugía de las cataratas
Cirugía de las cataratasVini Velas
 
Atlas oftalmología
Atlas oftalmologíaAtlas oftalmología
Atlas oftalmologíaaguitarte
 
Cirugia de Catarata
Cirugia de CatarataCirugia de Catarata
Cirugia de Catarataardjss
 
Carnaval2009 01
Carnaval2009 01Carnaval2009 01
Carnaval2009 01USB
 
Nw2014 msics the_beginning05
Nw2014 msics the_beginning05Nw2014 msics the_beginning05
Nw2014 msics the_beginning05Nawat Watanachai
 
Parejas de futbolistas
Parejas de futbolistasParejas de futbolistas
Parejas de futbolistaslas rozas
 
las chicas más lindas
las chicas más lindaslas chicas más lindas
las chicas más lindasermel gomez
 
Manual small incision cataract surgery
Manual small incision cataract surgeryManual small incision cataract surgery
Manual small incision cataract surgerymedusae1
 
Indicaciones y evaluación preoperatoria de la catarata
Indicaciones y evaluación preoperatoria de la catarataIndicaciones y evaluación preoperatoria de la catarata
Indicaciones y evaluación preoperatoria de la catarataDR. CARLOS Azañero
 

Andere mochten auch (20)

promocion 2009 oscar alfaro
promocion 2009 oscar alfaropromocion 2009 oscar alfaro
promocion 2009 oscar alfaro
 
Cara menggunakan mailing list di office 2007
Cara menggunakan mailing list di office 2007Cara menggunakan mailing list di office 2007
Cara menggunakan mailing list di office 2007
 
Wound construction For Cataract Surgery
Wound construction For Cataract SurgeryWound construction For Cataract Surgery
Wound construction For Cataract Surgery
 
Capacitación en salud ocular básica y sus derechos
Capacitación en salud ocular básica y sus derechosCapacitación en salud ocular básica y sus derechos
Capacitación en salud ocular básica y sus derechos
 
Tecnica de mininucleo
Tecnica de mininucleoTecnica de mininucleo
Tecnica de mininucleo
 
Dossier de Oftalmologia
Dossier de OftalmologiaDossier de Oftalmologia
Dossier de Oftalmologia
 
Romulo
RomuloRomulo
Romulo
 
Cirugía de las cataratas
Cirugía de las cataratasCirugía de las cataratas
Cirugía de las cataratas
 
Catarata
CatarataCatarata
Catarata
 
anatomia-ocular
anatomia-ocularanatomia-ocular
anatomia-ocular
 
Atlas oftalmología
Atlas oftalmologíaAtlas oftalmología
Atlas oftalmología
 
Programa de alta resolución en cirugía de catarata ambulante (ARCCA)
Programa de alta resolución en cirugía de catarata ambulante (ARCCA)Programa de alta resolución en cirugía de catarata ambulante (ARCCA)
Programa de alta resolución en cirugía de catarata ambulante (ARCCA)
 
Cirugia de Catarata
Cirugia de CatarataCirugia de Catarata
Cirugia de Catarata
 
Carnaval2009 01
Carnaval2009 01Carnaval2009 01
Carnaval2009 01
 
Nw2014 msics the_beginning05
Nw2014 msics the_beginning05Nw2014 msics the_beginning05
Nw2014 msics the_beginning05
 
Facofemto y mics
Facofemto y micsFacofemto y mics
Facofemto y mics
 
Parejas de futbolistas
Parejas de futbolistasParejas de futbolistas
Parejas de futbolistas
 
las chicas más lindas
las chicas más lindaslas chicas más lindas
las chicas más lindas
 
Manual small incision cataract surgery
Manual small incision cataract surgeryManual small incision cataract surgery
Manual small incision cataract surgery
 
Indicaciones y evaluación preoperatoria de la catarata
Indicaciones y evaluación preoperatoria de la catarataIndicaciones y evaluación preoperatoria de la catarata
Indicaciones y evaluación preoperatoria de la catarata
 

Ähnlich wie Sexy.js: A Sequential Ajax (Sajax) library for jQuery

Making Ajax Sexy, JSConf 2010
Making Ajax Sexy, JSConf 2010Making Ajax Sexy, JSConf 2010
Making Ajax Sexy, JSConf 2010Dave Furfero
 
Making Ajax Sexy, JSConf 2010
Making Ajax Sexy, JSConf 2010Making Ajax Sexy, JSConf 2010
Making Ajax Sexy, JSConf 2010guest3a77e5d
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick Lee
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Foreverstephskardal
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretssmueller_sandsmedia
 
Simplify AJAX using jQuery
Simplify AJAX using jQuerySimplify AJAX using jQuery
Simplify AJAX using jQuerySiva Arunachalam
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5Martin Kleppe
 
Test-driven Development with AEM
Test-driven Development with AEMTest-driven Development with AEM
Test-driven Development with AEMJan Wloka
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptGuy Royse
 
React.js or why DOM finally makes sense
React.js or why DOM finally makes senseReact.js or why DOM finally makes sense
React.js or why DOM finally makes senseEldar Djafarov
 
Backbone js in drupal core
Backbone js in drupal coreBackbone js in drupal core
Backbone js in drupal coreMarcin Wosinek
 
Writing RESTful web services using Node.js
Writing RESTful web services using Node.jsWriting RESTful web services using Node.js
Writing RESTful web services using Node.jsFDConf
 
Top Ten Web Defenses - DefCamp 2012
Top Ten Web Defenses  - DefCamp 2012Top Ten Web Defenses  - DefCamp 2012
Top Ten Web Defenses - DefCamp 2012DefCamp
 

Ähnlich wie Sexy.js: A Sequential Ajax (Sajax) library for jQuery (20)

Making Ajax Sexy, JSConf 2010
Making Ajax Sexy, JSConf 2010Making Ajax Sexy, JSConf 2010
Making Ajax Sexy, JSConf 2010
 
Making Ajax Sexy, JSConf 2010
Making Ajax Sexy, JSConf 2010Making Ajax Sexy, JSConf 2010
Making Ajax Sexy, JSConf 2010
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
Simplify AJAX using jQuery
Simplify AJAX using jQuerySimplify AJAX using jQuery
Simplify AJAX using jQuery
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5
 
jQuery, CSS3 and ColdFusion
jQuery, CSS3 and ColdFusionjQuery, CSS3 and ColdFusion
jQuery, CSS3 and ColdFusion
 
Test-driven Development with AEM
Test-driven Development with AEMTest-driven Development with AEM
Test-driven Development with AEM
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
jQuery
jQueryjQuery
jQuery
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
 
React.js or why DOM finally makes sense
React.js or why DOM finally makes senseReact.js or why DOM finally makes sense
React.js or why DOM finally makes sense
 
jQuery's Secrets
jQuery's SecretsjQuery's Secrets
jQuery's Secrets
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Backbone js in drupal core
Backbone js in drupal coreBackbone js in drupal core
Backbone js in drupal core
 
Writing RESTful web services using Node.js
Writing RESTful web services using Node.jsWriting RESTful web services using Node.js
Writing RESTful web services using Node.js
 
Top Ten Web Defenses - DefCamp 2012
Top Ten Web Defenses  - DefCamp 2012Top Ten Web Defenses  - DefCamp 2012
Top Ten Web Defenses - DefCamp 2012
 

Kürzlich hochgeladen

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Kürzlich hochgeladen (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Sexy.js: A Sequential Ajax (Sajax) library for jQuery

  • 2. Sexy.js Slideshow http://www.slideshare.net/furf
  • 3. Sexy.js A lightweight JavaScript library which provides enhanced Sequential Ajax (Sajax) functionality and a sleek facade to jQuery’s native Ajax methods.
  • 4. Sexy.js Facilitates combination and manipulation of data from multiple sources Speeds loading of scripts, stylesheets, and data using parallel asynchronous HTTP requests
  • 5. Ugly.js $.getJSON('articles.json', function (articles) { $.getJSON('comments.json', function (comments) { $.getJSON('ratings.json', function (ratings) { $.each(comments, function (i, comment) { articles[comment.articleId].comments.push(comment); }); $.each(ratings, function (i, rating) { articles[rating.articleId].rating = rating; }); }); }); });
  • 6. Sexy.js Sexy .json('articles.json') .json('comments.json', function (comments, status, articles) { $.each(comments, function (i, comment) { articles[comment.articleId].comments.push(comment); }); return articles; }) .json('ratings.json', function (ratings, status, articles) { $.each(ratings, function (i, rating) { articles[rating.articleId].rating = rating; }); });
  • 7. Ugly.js <script src="/js/jquery.template.min.js" type="text/javascript"></script> <link rel="stylesheet" href="css/comments.css" type="text/css"/> <script type="text/javascript"> $.get('comments.tpl', function (tpl) { $.getJSON('comments.json', function (data) { $.template(tpl, data).appendTo('#comments'); }); }); </script>
  • 8. Sexy.js <script type="text/javascript"> Sexy .js('jquery.template.min.js') .css('comments.css') .text('comments.tpl') .json('comments.json', function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); }); </script>
  • 10. Sequential Ajax (Sajax) Simultaneous request/sequential response Ajax Each successive callback receives the return value of the previous callback as an additional argument
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 38. Sexy.js API Core Methods html (url, callback) json (url, callback) jsonp (url, callback) script/js (url, callback) style/css (url, callback) text (url, callback) xml (url, callback)
  • 39. Sexy.js API Core Methods html (url, callback) html (settings) json (url, callback) json (settings) jsonp (url, callback) jsonp (settings) script/js (url, callback) script/js (settings) style/css (url, callback) style/css (settings) text (url, callback) text (settings) xml (url, callback) xml (settings)
  • 40. Sexy.js API callback (data, status, previous) Each callback receives three arguments: data status previous - the return value of the previous callback (considering a fourth) next or this
  • 41. Sexy.js API Additional Methods setup (settings) Similar to jQuery.ajaxSetup, but limited to subsequent calls of a Sexy instance Can be unset with setup() bundle (url1, url2, ..., callback) Client-side JavaScript packaging Multiple file, single <script> injection Sequence is preserved
  • 43. Using Sexy.js Loading JavaScripts Sexy .js('jquery.template.min.js')
  • 44. Using Sexy.js Loading Stylesheets (local only) Sexy .js('jquery.template.min.js') .css('comments.css')
  • 45. Using Sexy.js Loading Stylesheets (local only) Sexy .js('jquery.template.min.js') .css('comments.css')
  • 46. Using Sexy.js Loading Data Sexy .js('jquery.template.min.js') .css('comments.css') .text('comments.tpl', function (data) { return data; })
  • 47. Using Sexy.js Loading Data Sexy .js('jquery.template.min.js') .css('comments.css') .text('comments.tpl', function (data) { return data; }) .json('comments.json', function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); });
  • 48. Using Sexy.js Custom Ajax Settings Sexy .js('jquery.template.min.js') .css('comments.css') .text('comments.tpl', function (data) { return data; }) .json({ url: 'comments.json', data: { article_id: 123, }, success: function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); } });
  • 49. Using Sexy.js Passing Data with Callbacks Sexy .js('jquery.template.min.js') .css('comments.css') .text('comments.tpl', function (data) { return data; }) .json('comments.json?article_id=123', function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); });
  • 50. Using Sexy.js Implicit Callbacks Sexy .js('jquery.template.min.js') .css('comments.css') .text('comments.tpl', function (data) { return data; }) .json('comments.json?article_id=123', function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); });
  • 51. Using Sexy.js Implicit Callbacks Sexy .js('jquery.template.min.js') .css('comments.css') .text('comments.tpl', function (data) { return data; }) .json('comments.json?article_id=123', function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); });
  • 52. Using Sexy.js Implicit Callbacks, Non-Data Types Sexy .css('comments.css') .text('comments.tpl') .js('jquery.template.min.js', function (data, status, previous) { return previous; }) .json('comments.json?article_id=123', function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); });
  • 53. Using Sexy.js Implicit Callbacks, Non-Data Types Sexy .css('comments.css') .text('comments.tpl') .js('jquery.template.min.js') .json('comments.json?article_id=123', function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); });
  • 54. Using Sexy.js Configuring Sexy.js Sexy .setup({ cache: true }) .js('jquery.template.min.js') .css('comments.css') .text('comments.tpl') .json('comments.json', function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); });
  • 55. Using Sexy.js Configuring Sexy.js Sexy({ cache: true }) .js('jquery.template.min.js') .css('comments.css') .text('comments.tpl') .json('comments.json', function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); });
  • 56. Using Sexy.js Configuring Sexy.js Sexy({ cache: true }) .js('jquery.template.min.js') .css('comments.css') .text('comments.tpl') .setup({ cache: false }) .json('comments.json', function (data, status, tpl) { $.template(tpl, data).appendTo('#comments'); });
  • 57. Using Sexy.js Bundling JavaScripts Sexy .bundle( '/js/bam.js', ‘/js/bam.datagrid.js', ‘/js/bam.stats.js', ‘/js/bam.stats.widget.js', ‘/js/bam.stats.widget.leagueSelector.js', ‘/js/bam.stats.app.js', ‘/js/bam.stats.app.sortablePlayerList.js' );
  • 58. Using Sexy.js Bundling JavaScripts Sexy .bundle( '/js/bam.js', ‘/js/bam.datagrid.js', ‘/js/bam.stats.js', ‘/js/bam.stats.widget.js', ‘/js/bam.stats.widget.leagueSelector.js', ‘/js/bam.stats.app.js', ‘/js/bam.stats.app.sortablePlayerList.js', function (src) { SortablePlayerList.init(); } );
  • 59. Known Issues Unable to detect error events for remote requests jsonp (remoteUrl) script (remoteUrl) style (remoteUrl)* *style (remoteUrl) will actually fire success event even if load was unsuccessful (ie. 404)
  • 60. Sexy.js Enhanced Ajax functionality Expressive, chainable API Lightweight (1.3KB compressed)
  • 61. Thanks! Slideshow: http://www.slideshare.net/furf URL: http://sexyjs.com Demo: http://sexyjs.com/demos/comments Download: http:github.com/furf/Sexy Twitter: @sexyjs E-mail: furf@furf.com
  • 63. Sexy is the new Sexy Sexy() == new Sexy() function Sexy (cfg) { // Allow instantiation without new keyword if (!(this instanceof Sexy)) { return new Sexy(cfg); } this.cfgs = []; this.setup(cfg); this.evt = $(this); }
  • 64. Take it off... take it all off! Sexy.method(url) == (new Sexy()).method(url) // Alias instance methods as static methods of constructor $.each(Sexy.prototype, function (name, method) { Sexy[name] = function () { return method.apply(new Sexy(), arguments); }; });

Hinweis der Redaktion