问题
I am wanting to load javascript and css files via a resource loader. I was originally using LabJs but I found YepNope more elegant and easier to work with in my scenario. However I am finding it devastatingly slow, which is odd as apparently it is comparable to LabJs in speed on most things.
One thing I do have are Etags which I am sure will slow everything down as its still requesting from the server rather than just working off the client cache.
Anyway there isnt much outside of the main YepNope site, and they havent released a new version with the fixes on their issues list in a while, so I was wondering what other options there are out there...
My requirements are:
- Needs to load Css and Javascript
- Needs to do them all in parallel
- Can be loaded via Javascript
I wish YepNope was a bit more active but wanted to weigh up the other options...
回答1:
headjs has a lot of features and covers what you are asking for.
回答2:
I would throw require.js up for consideration. It will dynamically add script and css tags to the <head>
so it works nicely asynchronously. It will also optimize all your js into one file so if you project is like mine you'll have dozens of js files in development (I think we have about 100) but only 1 for production.
The only thing I haven't got working yet is the optimization of the css files though apparently it has been done.
Good luck
来源:https://stackoverflow.com/questions/7960166/alternatives-to-yepnope-and-labjs