Serve different JS files, depending on browser support?

Juan Ignacio Dopazo dopazo.juan at gmail.com
Thu Sep 5 07:11:08 PDT 2013


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.

Juan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130905/09d86d69/attachment.html>


More information about the es-discuss mailing list