Question

Ideally I'm looking for a Javascript resource loader that will:

(1) Allow me to make "ready" calls like head.js does, e.g.

head.ready(function() {
   $("#my").jquery_plugin();
});

// load jQuery whenever you wish bottom of the page
head.js("/path/to/jquery.js");

(2) Load CSS files like yepnope (which can also handle file names with hash on the end by using the css! prefix). I don't particularly need the conditional load functionality (at this stage).

(3) Ideally, only load resources once even if multiple calls are made (head.js does this automatically, yepnope does this with a filter).

At the moment I'm resorting to using both head.js and yepnope, as I haven't been able to find one that supports both the first two requirements. Obviously this is not ideal, as both together (with filters and prefixes) come to 7kb minified. I think this is a bit too heavy as a bootstrap script.

One option is roll my own using a combination of the two and strip out the functionality I don't need... but I'd rather stick to one that's going to be supported to reduce the pain of future updates etc.

Was it helpful?

Solution

So we stuck with a combination head.js and yepnope until something better comes out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top