I have a web app thats getting much bigger than expected, and it has
quite a few JS files. I was looking for a way to load them quicker, and
preferably asynchronous and with dependencies, meaning don't load
them ALL at once, but load the ones that don't have dependencies
(but ARE dependencies) first, then if they are loaded fine, load the
ones dependent on them, etc etc.
I looked into HeadJS (HJS) and RequireJS (RJS), and I had a few
questions about both.
I first started to use HJS, and it looks like I got it working
fine, but I'm just not sure I'm doing it right, if someone can
verify, that would be cool, code here:
http://pastebin.com/RCjpUKUS
So, first off... loading CSS asynchronous and with dependencies
just like it can with JavaScript would be a huge plus, and I
know HJS says it can do that, and I notice RJS says it cant, because
its "not possible" to do it properly. So that means that
either the developers of HJS knows something that the devs
of RJS don't, or that the devs of HJS settled for something
sloppy.. which would you say it is? (Granted, the sources that say its
not possible are over 8 years old, but theres nothing more recent to
debunk that)
After I used HJS a bit, I looked into RJS, and it looks a hell of a
lot more powerful than HJS. So I thought about implementing it into my
existing project. But as I started to look at some tutorials
(primarily
this one), I kinda got the feeling that its not
really something you can just throw existing code into, or just tell
it to load specific files in order with dependencies, it looks like it
kinda forces you to code your JS into a specific paradigm that they
require for you to use their model.. Is that the case? Or am I just
looking at it incorrectly.