I am currently implementing the innovative garber-irish technique to organize my JavaScript files.
Here's my issue: I have a Model (let's call it Item) with an init function located in app/assets/javascripts/item/item.js
For example:
MYAPP.items = {
init: function() {
alert("do something");
};
};
Now, let's say I have an admin section in my application, and I prefer not to include the admin JavaScript in the main bundle. So, I have a separate system_administration.js file that requires the regular javascripts/item/item.js mentioned above, but also requires a javascripts/admin/item/item.js like this:
MYAPP.items = {
init: function() {
alert("also do this");
};
};
I aim to load both the common JavaScript files and the administration-specific ones - essentially combining the two init functions and maintaining DRY (Don't Repeat Yourself) principles.
Queries:
- Is this a practical approach?
- Is it achievable?