SlideShare a Scribd company logo
1 of 30
Download to read offline
YUI3


   2011-7-30
•         / spring
    http://shangchun.net
    springuper@gmail.com


• 2010 12

•
•      YUI3
    YUI3


•
     Combo Loading
•

•

•
YUI2



             YUI3


YUI3   YUI
Chaining   Selector


AOP   YUI3
                              Loader


        OOP
var Y = YUI();
YUI.add(‘test’, function(Y) {        Y.use(‘test’, function(Y) {
      Y.sayHello = function() {            Y.sayHello(); // alert
           alert(‘Hello, world!’);   });
      };                             YUI().use(function(Y) {
});                                        Y.sayHello(); // error
                                     });
add
YUI.prototype.add = function(name, fn, details) {
     // register on the global object YUI
     YUI.Env.mods[name] = {
          name: name,
          fn: fn,
          details: details || {}
     };
     return this;
};
YUI.add = YUI.prototype.add;
use
YUI.prototype.use = function() {
   var Y = this, r = [],
       args = Array.prototype.slice.call(arguments, 0),
       callback = args[args.length - 1],
       process = function(names) { ... };
   args.pop();
   process(args); // calculate sorted full module list r
   Y._attach(r); // add the apis to Y
   callback(Y);
   return this;
};
Module vs <script>


•

•

•

•
YUI3

            Drag & Drop Animation
Component    IO Cookie JSON ...


Component        Widget Base
Framework       Attribute Plugin

                 DOM Node
  Core           Event OOP

  Seed                YUI
•

• Combo

• Loading

•
mis crm finance stat...   www ecom...
•

•

•

•
javascript

                   mis-deal mis-order
  Site App     finance-pay stat-compete ...


 Site Core       mis-base www-base ...


                mt-base w-base w-table
   Core           w-autocomplete ...

Base & Frame             YUI3
mis-order                mis-misc    ...



www-base     mis-base       w-base   w-autocomplete ...


                  mt-base                    vendor


            yui node event io ...
mt.js [mt-base] w-base.js [w-base]
          core         w-tab.js [w-tab] w-date.js [w-date] ...


         www                    in the near future


                       base.js [mis-base] deal.js [mis-deal]
static    mis    js   order.js [mis-order] misc.js [mis-misc]


         finance js              pay.js [finance-pay]



         vendor js       jquery.min.js zeroClipboard.js ...


           ...
var M = window.M || {};
M._YUI = YUI;
M.add = function() {
     M._YUI.add.apply(M._YUI, arguments);
     return this;
};
M.use = function() {
     var instance = M._YUI(YUI_META);
     instance.use.apply(instance, arguments);
     return this;
};
// static/mis/js/deal.js
(function() {
M.add(‘mis-deal’, function(Y) {
        var $MIS = Y.mt.mis, isIE = Y.UA.ie ... // shortcut
        var CONST = ‘const value‘ ... // const
        Y.namespace(‘mt.mis.Deal’);
        Y.mt.mis.Deal = {
             editInfo:function(param) { ... }
        };
}, ‘1.0.0’, { requires:M.Groups[‘mis’][‘modules’][‘deal’].requires });
})();
// helper/FileHelper.php
private static $groups = array(
     ‘core’ => array(...),
     ‘www’ => array(...),
     ‘mis’ => array(
           ‘mis-deal’ => array(
                ‘path’ => ‘mis/js/deal.js’,
                ‘requires’ => array(‘mis-base’, ‘w-tab’),
           ),
     ),
     ...
);
Combo
           Minify (BSD, http://code.google.com/p/minify/)

// debug
FirePHP


// bad request header, CDN caches 400
$min_serveOptions[‘badRequestHeader’] = ‘HTTP/1.0 404 Not Found’;


// stop minifiers
$min_serveOptions[‘minifiers’] [‘application/x-javascript’] = null;
$min_serveOptions[‘minifiers’] [‘text/css’] = null;
Loader
// php frame
$loader = new YUILoader(                    PHP Loader
      FileHelper::YUI3_VERSION,
      FilerHelper::getMTModules()
);


// template
$loader->misInit(‘mis-deal’, “
     Y.mt.mis.Deal.editInfo(‘. $status. ’, ‘ . $modReason. ’);
“);
http://c.meituan.net/f=static/mis/js/base.v1692bda7.js,static/core/w-
core.vea9d9098.js,static/core/w-base.v24ec835d.js,static/vendor/js/data-
pinyin.vc77e80e1.js,static/core/w-autocomplete.vd0296db5.js,static/core/
w-table.vcb4c553c.js,static/core/w-date.vc94a7365.js,static/core/w-
validate.va0f58428.js


                             v + md5
•

• YUI3 - below the surface Luke Smith

•   YUI2   YUI3

•
• MacBook Pro

• 27” IPS

• ENJOY
Thanks
 Q &A

More Related Content

What's hot

Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.js
Jarod Ferguson
 
Comment pages 002
Comment pages 002Comment pages 002
Comment pages 002
RiNi Ft
 
Kick start with j query
Kick start with j queryKick start with j query
Kick start with j query
Md. Ziaul Haq
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
Simon Willison
 

What's hot (16)

Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.js
 
5. chapter iv
5. chapter iv5. chapter iv
5. chapter iv
 
Beyond the DOM: Sane Structure for JS Apps
Beyond the DOM: Sane Structure for JS AppsBeyond the DOM: Sane Structure for JS Apps
Beyond the DOM: Sane Structure for JS Apps
 
PowerCMS X
PowerCMS XPowerCMS X
PowerCMS X
 
Drupal, meet Assetic
Drupal, meet AsseticDrupal, meet Assetic
Drupal, meet Assetic
 
Es6 modules-and-bundlers
Es6 modules-and-bundlersEs6 modules-and-bundlers
Es6 modules-and-bundlers
 
iOSインタラクションデザイン
iOSインタラクションデザインiOSインタラクションデザイン
iOSインタラクションデザイン
 
Comment pages 002
Comment pages 002Comment pages 002
Comment pages 002
 
Php if
Php ifPhp if
Php if
 
"Coffee Script" in Brief
"Coffee Script" in Brief"Coffee Script" in Brief
"Coffee Script" in Brief
 
Daniel Jalkut - dotSwift 2019
Daniel Jalkut - dotSwift 2019Daniel Jalkut - dotSwift 2019
Daniel Jalkut - dotSwift 2019
 
Kick start with j query
Kick start with j queryKick start with j query
Kick start with j query
 
怖くない!Implicit!
怖くない!Implicit!怖くない!Implicit!
怖くない!Implicit!
 
Rediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The LibrariesRediscovering JavaScript: The Language Behind The Libraries
Rediscovering JavaScript: The Language Behind The Libraries
 
There's a Filter For That
There's a Filter For ThatThere's a Filter For That
There's a Filter For That
 
Oo
OoOo
Oo
 

Viewers also liked

前端专利那些事儿
前端专利那些事儿前端专利那些事儿
前端专利那些事儿
tblanlan
 
July.2011.w3ctech
July.2011.w3ctechJuly.2011.w3ctech
July.2011.w3ctech
Kai Cui
 
一个前端Js模板引擎的实现和优化
一个前端Js模板引擎的实现和优化一个前端Js模板引擎的实现和优化
一个前端Js模板引擎的实现和优化
tblanlan
 
Javascript template
Javascript templateJavascript template
Javascript template
Kai Cui
 
GitLab—the new workbench
GitLab—the new workbenchGitLab—the new workbench
GitLab—the new workbench
tblanlan
 

Viewers also liked (6)

前端专利那些事儿
前端专利那些事儿前端专利那些事儿
前端专利那些事儿
 
July.2011.w3ctech
July.2011.w3ctechJuly.2011.w3ctech
July.2011.w3ctech
 
一个前端Js模板引擎的实现和优化
一个前端Js模板引擎的实现和优化一个前端Js模板引擎的实现和优化
一个前端Js模板引擎的实现和优化
 
Javascript template
Javascript templateJavascript template
Javascript template
 
GitLab—the new workbench
GitLab—the new workbenchGitLab—the new workbench
GitLab—the new workbench
 
用十分鐘瞭解 陳鍾誠的程式設計課 (採用JavaScript + C的原因)
用十分鐘瞭解  陳鍾誠的程式設計課  (採用JavaScript + C的原因)用十分鐘瞭解  陳鍾誠的程式設計課  (採用JavaScript + C的原因)
用十分鐘瞭解 陳鍾誠的程式設計課 (採用JavaScript + C的原因)
 

Similar to Yui3在美团 2

夜宴52期《从函数构造到YUI沙箱》
夜宴52期《从函数构造到YUI沙箱》夜宴52期《从函数构造到YUI沙箱》
夜宴52期《从函数构造到YUI沙箱》
Koubei Banquet
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
Adam Lu
 
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
smueller_sandsmedia
 
YUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax ExperienceYUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax Experience
Christian Heilmann
 

Similar to Yui3在美团 2 (20)

Yui3在美团
Yui3在美团Yui3在美团
Yui3在美团
 
夜宴52期《从函数构造到YUI沙箱》
夜宴52期《从函数构造到YUI沙箱》夜宴52期《从函数构造到YUI沙箱》
夜宴52期《从函数构造到YUI沙箱》
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
 
YUI on the go
YUI on the goYUI on the go
YUI on the go
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
YUI (Advanced)
YUI (Advanced)YUI (Advanced)
YUI (Advanced)
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui2009 Hackday Taiwan Yui
2009 Hackday Taiwan Yui
 
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
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
 
YUI 3
YUI 3YUI 3
YUI 3
 
Embracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend PerfEmbracing YUI3 and Frontend Perf
Embracing YUI3 and Frontend Perf
 
Yui intro
Yui introYui intro
Yui intro
 
jQuery: Events, Animation, Ajax
jQuery: Events, Animation, AjaxjQuery: Events, Animation, Ajax
jQuery: Events, Animation, Ajax
 
YUI for your Hacks
YUI for your Hacks YUI for your Hacks
YUI for your Hacks
 
JavaScript Everywhere! Creating a 100% JavaScript web stack
JavaScript Everywhere! Creating a 100% JavaScript web stackJavaScript Everywhere! Creating a 100% JavaScript web stack
JavaScript Everywhere! Creating a 100% JavaScript web stack
 
How I started to love design patterns
How I started to love design patternsHow I started to love design patterns
How I started to love design patterns
 
YUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax ExperienceYUI for control freaks - a presentation at The Ajax Experience
YUI for control freaks - a presentation at The Ajax Experience
 
Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010Running YUI 3 on Node.js - JSConf 2010
Running YUI 3 on Node.js - JSConf 2010
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 

Recently uploaded

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
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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...
 

Yui3在美团 2