CSS and JS resrouces
Sometimes you don't want to add css and js resources to the entire website because it is only needed on one page of the site.
For example, the accordion is often only used on the FAQ page, so why would you want the Accordion jQuery plugin's added to the whole site? This will decrease performance.
Run js code
You may have some js code that you only want to run when a Module is present. There are multiple ways that we can do this:
Write your js code in the Module and make sure to inject it into the bottom of the page.
This encapsulates the Module and makes it really easy to read and understand.
I would use this method when you are just instantiating a plugin because it's simple. Id you have to write a bunch of code, maybe you want to look at another method below.
Add a div onto the page and set the callback attribute
You can set up a function on the Module and then call it from the base-function.js file. This is helpful if you need to run the function on window resize - the definition for that is in base-functions.