requireJS optional dependency
问题 I'm adding AMD support to a javascript library I develop. This library may use jquery but it will still work if jquery isn't loaded. When defining the module dependency there's a way to set a dependency as 'optional' so that if that library is missing the module will still work? 回答1: I've had exactly the same problem recently, and here's how I fixed it. I defined a RequireJS plugin called optional which ignores modules that fail to load by explicitly defining them as an empty object (but I