I'm a developer, not a writer
What I ended up doing is first, in my base template which all other templates extend, I did this
Normally you are shown to have a data-main attribute on there which references a js file to start running right away. If you do that you can't have your global config all in one spot, though. So after that line I put in my global config like below, which allowed me to solve the other two problems.
You can see in the
shim section I have
csrf: ['jquery'] which tells it to load jquery before csrf (which it defaults to looking for in baseUrl) even though csrf.js is not set up for Require and AMD. I may not be 100% accurate on that description as I'm still fumbling about a bit with RequireJS configuration and behavior, but that is how I understood it from reading their docs. Then you can see in the
deps section I specify some libs to load and the there's a
callback section, which gets called after all of the dependencies in the
One thing to be aware of with the
callback is that my understanding after reading the docs is that those may not be guaranteed to have loaded by the time other scripts being loaded using RequireJS have already loaded, so it's possible those settings would not yet be set. I haven't run into any trouble with that in any testing I've done since making the change, though.