I'm trying to define a module with conditional dependencies (depending on Modernizr test). I've done something that works but feel hacky to me.

Can you tell me what you think and if there is a better way to do it? Thanks.

var dependencies = ["jquery"];

require(["modernizr"], function() {
  if(Modernizr.canvas) dependencies.push("modernizr/excanvas");
});

define(dependencies, function($) {

  $(function() {
    // code here
  });

});
Edit
Report