开发者

jQuery.getScript vs yepnope performance

I googled quite a lot looking for the answer to this question but didn't find anything.

Aside of additionnal functionalities offered by a script loader like yepnope, is it going to give me better performance and better cache management than jQuery.getScr开发者_如何学Pythonipt?

Thanks in advance,

Simon


In principle, their functionally the same. The biggest gain you get from something like yepnope is integrated conditional loading. Whereas, with $.getScript, you'd have to do any requisite boolean checks manually. There's also little things like the fact that yepnope is already supported by tests, whereas if you wanted the same certainty in your custom conditional-loading code, you'd have to write your own.

In short, yepnope is just a time-saver like jQuery itself is a time-saver. There's nothing you can do in jQuery that you can't do in vanilla JavaScript; it just takes more time, energy, and effort. If you're thinking about dynamically loading scripts, I would recommend that you use a library for that, instead of re-inventing the wheel.

Interestingly, yepnope is actually bundled into Modernizr (I didn't know that). So, if you're looking to start getting into HTML5, you can include Modernizr and get your shivs, feature-sensing sugar, and dynamic script loading all in one.


You can also use head.js if you are loading multiple JS files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜