Recently I was working on moving my projects from YUI 2.x to YUI 3.x. Here I want to share my experience and solution.
Firts, I guess you red the article: "Working with YUI 2 in 3" (http://yuilibrary.com/yui/docs/yui/yui-yui2.html). Unfortunatelly, this approach forced you to cover all your existing JS code into new structures called modules like
YUI.add('mymodule-uses-yui2', function(Y) {
var YAHOO = Y.YUI2;
/* my old JS code based on YUI 2 placed here */
}, '1.0', {requires: 'yui2-modules'});
and then use that modules in a sandbox:
YUI().use('...', 'yui2-modules', 'mymodule-uses-yui2', function(Y) {
var YAHOO = Y.YUI2;
});
This causes a lot of work on existing codebase to create modules and correct dependecies.
I found that I can avoid it on the first stage of recatoring: I keep loading all YUI 2 components staticaly in script tag as always did. In this case global YAHOO object is available everywhere and my old code just works. Then I started to write a new code (or rewrite old code) using YUI 3 near my old code - no conficts at all! You can also step by step cover your old code into new fashion modules (YUI.add) and still use global YAHOO there (without using Y.YUI2). And you do not need to force all you power to cover all old code into new modules at one time.
I also found SimpleYUI more usefull for me vs. sandboxing every time into YUI().use(...) because currentelly I have a lot of places on the page where I need just one small peace of JS code. SimpleYUI do it better, if you have you code on the page in several places and do not have time to completelly refactor it yet.
<script>
tag. I don't think ause()
call is necessary in that case. Have you tried that? – Gabe Moothartyahoo.js
(oryuiloader.js
) file to the 2in3 version – Gabe Moothart