Juan Ignacio Dopazo (2013-09-05T14:11:08.000Z)
domenic at domenicdenicola.com (2013-09-08T01:05:26.246Z)
Conditionally loading modules is also built into YUI. For example, when you want to use JSON, YUI checks if the native version is present and if not it loads a JS implementation. You have to do it feature by feature. I recently wrote a Taskjs like generators+promises implementation and it checks which syntax is supported (ES6 or the old Firefox one without function*) by using eval() and catching syntax errors. See https://github.com/juandopazo/yui3-task/blob/master/js/task.js#L43-L55. It doesn't load a new module based on that check because the code is not big enough to warrant loading a whole new script.