SlideShare a Scribd company logo
1 of 12
Download to read offline
HackU 2013
University of Dundee
         February 2013
What exactly is YUI?!?




HackU 2013 – University of Dundee
A Javascript Library or a Japanese singer?




 More than just a library, it has become a
 full-fledged CSS & Javascript framework


HackU 2013 – University of Dundee
How does it compare to JQuery?




HackU 2013 – University of Dundee
Let’s go through their features
 Feature                            YUI   JQuery   Alternative (not exhaustive list)


 DOM Manipulation                   1       1

 AJAX requests                      1       1

 Event binding                      1       1

 Model-View-Controller              1       0      Backbone.js

 URL Router                         1       0      Path.js / Crossroads.js

 Viewstate history                  1       0      Backbone.js

 Charting                           1       0      Flot

 Client-side templating             1       0      Underscore

 Advanced object manipulation       1       0      Underscore




HackU 2013 – University of Dundee
…and the list goes on
 Feature                                 YUI   JQuery   Alternative (not exhaustive list)


 Asynchronous modules loading            1       0      Require.js

 Custom builds                           1       0

 Table sorting                           1       0      Datatables

 CSS Scaffolding                         1       0      Twitter’s Bootstrap

 Cross-browser CSS initializer           1       0      Reset CSS

 Native YQL support                      1       0

 Tabbed views                            1       0      Twitter’s Bootstrap

 Widgets (tab-views, color/datepicker)   1       0      JQuery UI

 Colorpicker widget                      1       0      JQuery UI


                                                                                etc…
HackU 2013 – University of Dundee
One last fundamental difference…

§  Every bit of code is sandboxed ie. wrapped in the YUI().use method




  §  Limits conflicts with other frameworks/libraries. Only the YUI namespace is taken.
  §  Variables inside the sandbox are ONLY available… inside the sandbox.
  §  Creating a module is easy as a sandbox can easily be turned into a module:
      §  Change the use method to the add one
      §  Declare functions as methods
      §  Give a name to your module
      §  Specify its dependencies
      §  Share it with the community!




HackU 2013 – University of Dundee
Let’s write some code!

§  Exercise: create HTML from an AJAX request & a template file
§  Skills: HTML, JS, YUI, AJAX, YUI’s Micro-templates
§  Modules we will use:
  §  Node for DOM Manipulation
  §  IO for making AJAX requests
  §  Template for client-side templating
  §  Console for debugging (to be removed in a production environment)
§  Step by step flow:
  §  Initial HTML page is loaded
  §  1st AJAX request retrieves template source
  §  The template source is compiled into a javascript function
  §  2nd AJAX request retrieves data in JSON format
  §  Previous data is passed to the compiled function to generate the HTML code
  §  New HTML code is inserted into the initial one.




HackU 2013 – University of Dundee
Project directory structure

§  index.html
§  js/
  §  yui-min.js
§  models/
  §  demo.json
  §  …JSON files asynchronously loaded (could be from an external server through an API)

§  views/
  §  list.handlebars
  §  table.handlebars
  §  …any other template file




HackU 2013 – University of Dundee
Code overview & demo time!




HackU 2013 – University of Dundee
With great power, comes… great hacks!
                      YUI is free so play with it and amaze us :)

        (it’s also open-source so don’t hesitate to contribute to the Gallery)




HackU 2013 – University of Dundee
YUI Jedi links
User guides: http://yuilibrary.com/yui/docs/guides/
Full modules list: http://yuilibrary.com/yui/docs/yui/modules.html
Gallery of contributions: http://yuilibrary.com/gallery/


Demo Code: http://bit.ly/YDNHHd




 HackU 2013 – University of Dundee

More Related Content

Similar to Dundee University HackU 2013 - YUI

Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQueryAnil Kumar
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesMark Roden
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)jeresig
 
Build your web apps with yql and yui
Build your web apps with yql and yuiBuild your web apps with yql and yui
Build your web apps with yql and yuiISOCHK
 
2a-JQuery AJAX.pptx
2a-JQuery AJAX.pptx2a-JQuery AJAX.pptx
2a-JQuery AJAX.pptxLe Hung
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web ApplicationYakov Fain
 
JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)jeresig
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overviewjeresig
 
Javascript library toolbox
Javascript library toolboxJavascript library toolbox
Javascript library toolboxSkysoul Pty.Ltd.
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)jeresig
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)jeresig
 
JS Libraries and jQuery Overview
JS Libraries and jQuery OverviewJS Libraries and jQuery Overview
JS Libraries and jQuery OverviewAleksandr Motsjonov
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overviewjeresig
 
JS Single-Page Web App Essentials
JS Single-Page Web App EssentialsJS Single-Page Web App Essentials
JS Single-Page Web App EssentialsSergey Bolshchikov
 
Do you need jQuery in 2019?
Do you need jQuery in 2019?Do you need jQuery in 2019?
Do you need jQuery in 2019?LindaHsu19
 
Hacking with YUI 3 - Open Hack Day 2011
Hacking with YUI 3 - Open Hack Day 2011Hacking with YUI 3 - Open Hack Day 2011
Hacking with YUI 3 - Open Hack Day 2011knutties
 
Declarative and standards-based web application development with the Ample SDK
Declarative and standards-based web application development with the Ample SDKDeclarative and standards-based web application development with the Ample SDK
Declarative and standards-based web application development with the Ample SDKBéla Varga
 

Similar to Dundee University HackU 2013 - YUI (20)

Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
 
Build your web apps with yql and yui
Build your web apps with yql and yuiBuild your web apps with yql and yui
Build your web apps with yql and yui
 
2a-JQuery AJAX.pptx
2a-JQuery AJAX.pptx2a-JQuery AJAX.pptx
2a-JQuery AJAX.pptx
 
Jquery beltranhomewrok
Jquery beltranhomewrokJquery beltranhomewrok
Jquery beltranhomewrok
 
Jquery beltranhomewrok
Jquery beltranhomewrokJquery beltranhomewrok
Jquery beltranhomewrok
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web Application
 
JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)JavaScript Libraries (Ajax Exp 2006)
JavaScript Libraries (Ajax Exp 2006)
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overview
 
Javascript library toolbox
Javascript library toolboxJavascript library toolbox
Javascript library toolbox
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)
 
JS Libraries and jQuery Overview
JS Libraries and jQuery OverviewJS Libraries and jQuery Overview
JS Libraries and jQuery Overview
 
Jquery
JqueryJquery
Jquery
 
JavaScript Library Overview
JavaScript Library OverviewJavaScript Library Overview
JavaScript Library Overview
 
JS Single-Page Web App Essentials
JS Single-Page Web App EssentialsJS Single-Page Web App Essentials
JS Single-Page Web App Essentials
 
Do you need jQuery in 2019?
Do you need jQuery in 2019?Do you need jQuery in 2019?
Do you need jQuery in 2019?
 
Hacking with YUI 3 - Open Hack Day 2011
Hacking with YUI 3 - Open Hack Day 2011Hacking with YUI 3 - Open Hack Day 2011
Hacking with YUI 3 - Open Hack Day 2011
 
Declarative and standards-based web application development with the Ample SDK
Declarative and standards-based web application development with the Ample SDKDeclarative and standards-based web application development with the Ample SDK
Declarative and standards-based web application development with the Ample SDK
 

Dundee University HackU 2013 - YUI

  • 1. HackU 2013 University of Dundee February 2013
  • 2. What exactly is YUI?!? HackU 2013 – University of Dundee
  • 3. A Javascript Library or a Japanese singer? More than just a library, it has become a full-fledged CSS & Javascript framework HackU 2013 – University of Dundee
  • 4. How does it compare to JQuery? HackU 2013 – University of Dundee
  • 5. Let’s go through their features Feature YUI JQuery Alternative (not exhaustive list) DOM Manipulation 1 1 AJAX requests 1 1 Event binding 1 1 Model-View-Controller 1 0 Backbone.js URL Router 1 0 Path.js / Crossroads.js Viewstate history 1 0 Backbone.js Charting 1 0 Flot Client-side templating 1 0 Underscore Advanced object manipulation 1 0 Underscore HackU 2013 – University of Dundee
  • 6. …and the list goes on Feature YUI JQuery Alternative (not exhaustive list) Asynchronous modules loading 1 0 Require.js Custom builds 1 0 Table sorting 1 0 Datatables CSS Scaffolding 1 0 Twitter’s Bootstrap Cross-browser CSS initializer 1 0 Reset CSS Native YQL support 1 0 Tabbed views 1 0 Twitter’s Bootstrap Widgets (tab-views, color/datepicker) 1 0 JQuery UI Colorpicker widget 1 0 JQuery UI etc… HackU 2013 – University of Dundee
  • 7. One last fundamental difference… §  Every bit of code is sandboxed ie. wrapped in the YUI().use method §  Limits conflicts with other frameworks/libraries. Only the YUI namespace is taken. §  Variables inside the sandbox are ONLY available… inside the sandbox. §  Creating a module is easy as a sandbox can easily be turned into a module: §  Change the use method to the add one §  Declare functions as methods §  Give a name to your module §  Specify its dependencies §  Share it with the community! HackU 2013 – University of Dundee
  • 8. Let’s write some code! §  Exercise: create HTML from an AJAX request & a template file §  Skills: HTML, JS, YUI, AJAX, YUI’s Micro-templates §  Modules we will use: §  Node for DOM Manipulation §  IO for making AJAX requests §  Template for client-side templating §  Console for debugging (to be removed in a production environment) §  Step by step flow: §  Initial HTML page is loaded §  1st AJAX request retrieves template source §  The template source is compiled into a javascript function §  2nd AJAX request retrieves data in JSON format §  Previous data is passed to the compiled function to generate the HTML code §  New HTML code is inserted into the initial one. HackU 2013 – University of Dundee
  • 9. Project directory structure §  index.html §  js/ §  yui-min.js §  models/ §  demo.json §  …JSON files asynchronously loaded (could be from an external server through an API) §  views/ §  list.handlebars §  table.handlebars §  …any other template file HackU 2013 – University of Dundee
  • 10. Code overview & demo time! HackU 2013 – University of Dundee
  • 11. With great power, comes… great hacks! YUI is free so play with it and amaze us :) (it’s also open-source so don’t hesitate to contribute to the Gallery) HackU 2013 – University of Dundee
  • 12. YUI Jedi links User guides: http://yuilibrary.com/yui/docs/guides/ Full modules list: http://yuilibrary.com/yui/docs/yui/modules.html Gallery of contributions: http://yuilibrary.com/gallery/ Demo Code: http://bit.ly/YDNHHd HackU 2013 – University of Dundee