说服我从 YUI 2 切换到 YUI 3

发布于 2024-08-15 03:35:35 字数 118 浏览 2 评论 0原文

我一直在使用 YUI Library 来开发网站。 YUI 3 于 9 月发布。

我仍然不确定是否必须为迁移做好准备。

第三版比第二版有什么优势?

您最近参与过这样的迁移吗?

I've been using YUI Library to develop websites. YUI 3 came out on september.

I'm still not convinced if i have to prepare myself for a migration.

What are the advantages of 3rd version over the 2nd ?

Have you been involved in such a migration, lately ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

时光瘦了 2024-08-22 03:35:35

我没有参与迁移,但我为 YUI 3 画廊做出了贡献,而且我也知道有一个画廊条目允许 YUI 2 中的任何类在 YUI 3 中使用。我猜 YUI 3 的主要优点是能够按需加载您想要的内容。您包含 1 个 javascript 文件,然后使用以下行来使用 yui 中您想要的任何模块。

YUI().use('dom',function(){
 // your code here
});

这样做的优点是它加载了 DOM 模块,并且仅在该函数的范围内可用。这很好,因为它只加载特定范围内所需的模块。如果您使用它们,这将防止与任何其他 JS 框架发生冲突。

如果你想添加你自己的自定义模块,你会做这样的事情,

YUI().add('mycustompackage',function(Y){
    MyCustom.package.SomeClass = function(){}
    MyCustom.package.SomeClass.prototype = {}
},'1.0.0',{requires:['base','dom','event'],use:['node']});

这将添加你的模块,并注册依赖项,这样你就可以使用它,说

YUI().use('mycustompackage',function(){
 // code goes here
});

我猜从我所看到的来看,主要优点是更安全和便携式框架。您可以使 YUI 3 模块仅在给定的功能范围内可用。如果您愿意,这可以释放页面的主要范围以用于其他事情。它也更安全,您的函数的定义位于私有范围内,因此它们没有全局变量钩子可供脚本注入等利用。

I have not been involved in a migration, but I have contributed to the YUI 3 gallery, and I also know there is a gallery entry that allows any class from YUI 2 to be used in YUI 3. I guess the main advantage of YUI 3 is the ability to load in what you want on demand. You include 1 javascript file, and then would use the following line to use whatever modules in yui you want.

YUI().use('dom',function(){
 // your code here
});

The advantage of this is it laods the DOM module, and makes available ONLY in the scope of that function. This is good because it only loads the modules you want in a specific scope. This will prevent clashes with any other JS frameworks if you use them.

If you want to add your own custom module you would do something like this

YUI().add('mycustompackage',function(Y){
    MyCustom.package.SomeClass = function(){}
    MyCustom.package.SomeClass.prototype = {}
},'1.0.0',{requires:['base','dom','event'],use:['node']});

That will add your module, and register the dependencies, so then you can use it by saying

YUI().use('mycustompackage',function(){
 // code goes here
});

I guess from what I can see, the main advantages are a more secure and portable framework. You can make the YUI 3 modules available ONLY within a given function scope. THis frees up the main scope of the page for other things if you wish. Its also more secure, the definition of your functions are in a private scope, so they have no global variable hooks to be exploited by say script injection or what not.

猥琐帝 2024-08-22 03:35:35

阿诺 - 这是我的答案:

http://developer .yahoo.com/yui/theater/video.php?v=miraglia-yuiconf2009-yui3

这是卢克的答案(更好!):

http://developer.yahoo.com/yui/theater/video.php?v=smith-yuiconf2009-events

哦,托德的回答(也很棒):

http: //developer.yahoo.com/yui/theater/video.php?v=kloots-yuiconf2009-sugar

YUI 3 对我们来说是向前迈出的一大步——我们对基本架构感到非常兴奋,以及我们从进行迁移的人们那里得知,他们喜欢 YUI 3 体验。我们需要让小部件继续运行 3,但我们正在努力(请参阅 http://developer.yahoo.com/yui/theater/video.php?v=desai-yuiconf2009-widgets )。

我不太客观,但我从那些客观的人那里听到了好话。

-埃里克

Arno -- here's my answer:

http://developer.yahoo.com/yui/theater/video.php?v=miraglia-yuiconf2009-yui3

Here's Luke's answer (even better!):

http://developer.yahoo.com/yui/theater/video.php?v=smith-yuiconf2009-events

Oh, and Todd's answer (also fantastic):

http://developer.yahoo.com/yui/theater/video.php?v=kloots-yuiconf2009-sugar

YUI 3 is a big step forward for us -- we're really excited about the basic architecture, and what we're hearing from people who are making the migration is that they love the YUI 3 experience. We need to get the widgets going on 3, but we're working on that (see http://developer.yahoo.com/yui/theater/video.php?v=desai-yuiconf2009-widgets ).

I'm not remotely objective, but I hear good things from those who are.

-Eric

烂人 2024-08-22 03:35:35

没有必要迁移。您可以开始使用 YUI 3 和 YUI 2,我鼓励您这样做。

YUI 3 背后的想法和架构给我留下了深刻的印象。例如,YUI 3 如何标准化节点和事件处理以及如何像本机事件一样处理自定义事件。

库的模块化不仅使其更易于使用,而且促进了您自己编写更加模块化的代码,这是一件好事。

观看 Eric 的介绍视频以及 YUI Theater 中的所有其他 YUI 3 视频,了解更多制作理由开关。

There's no need to migrate. You can start using YUI 3 right along side YUI 2, and I encourage you to do so.

I'm very impressed with the ideas and architecture behind YUI 3. For example how YUI 3 normalizes node and event handling and how custom events are handled like native events.

The modularity of the library not only makes it easier to use but promotes the writing of more modular code yourself, which is a good thing.

Take a look at Eric's introduction video and all the other YUI 3 videos at the YUI Theater to see more reasons to make the switch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文