You could put them in a namespace:
- can.Control.extend('Controls.MyControl', {});
will automatically create a reference:
- window.Controls.MyControl
so you can use dynamic access on the Controls namespace, instead of
the global namespace.
And if you are using a module system, e.g. RequireJS or StealJS,
you can reduce global pollution even further:
- // controls/my_control.js
- define(['can/control'], function(Control) {
- return Control.extend('MyControl', {});
- });
-
- // controls.js
- define(['controls/my_control', 'controls/another_control'], function(MyControl, AnotherControl) {
- return { MyControl: MyControl, AnotherControl: AnotherControl };
- });