Performance overhead of javascript libraries

Does anyone know if there are studies done that show the performance overhead of using javascript libraries (other than the obvious of their download time) vs using just basic javascript? The libraries are so huge these days and I was curious.

From my computer science degree it seems it should have growth n. (in other words linear).

In computer science terms this is non threatening but how does it actually effect page loading time and page performance in milliseconds? I know CPU is an issue, RAM, and so on. But are there any test performed that can gauge these sorts of things?

I know another factor is libraries are often optimized to do much the same thing you'd be coding by hand in a less optimized fashion but also libraries have overhead and not all of that functionality will be used.

Edit: I found this that seems to answer my question thoroughly even though it started out about something else: When to use Vanilla JavaScript vs. jQuery?

"As the comments are quick to point out (and I agree with 100%) the statements above refer to benchmarking code. A 'native' JavaScript solution (assuming it is well written) will outperform a jQuery solution that accomplishes the same thing in nearly every case (I'd love to see an example otherwise). jQuery does speed up development time, which is a significant benefit which I do not mean to downplay. It facilitates easy to read, easy to follow code, which is more than some developers are capable of creating on their own.

In my opinion then, the answer depends on what you're attempting to achieve. If, as I presumed based on your reference to performance benefits, you're after the best possible speed out of your application, then using jQuery introduces overhead every time you call $(). If you're going for readability, consistency, cross browser compatibility, etc, then there are certainly reasons to favor jQuery over 'native' JavaScript."


This is a good question! Next to the download time of the library itself, most of the frameworks are not doing very much, which means they do not delay page showing up or something.

JQuery's $.css method, which makes it easy to style elements can be become a performance bottleneck if you need to trigger this very often and operating directly on the style object is much faster.

I my opinion is better to do more with plain javascript, the more you have to gain high performance. For normal stuff like ajax requests, menu-fading and so on the performance of all the frameworks I have ever used is enough, and coding itself speeds up in turn.


It depends entirely on the library. However for libraries like jQuery it probably doesn't matter: the performance bottleneck is probably not jQuery, Google provide a CDN-hosted jQuery so it need not even impact the page load time, and the ease of use which jQuery gives you far, far outweighs the minor performance impact. Libraries can also use uncommon or difficult techniques to boost performance, so using a library can sometimes even be faster than what you would write yourself. There's no final answer really.


While not being a direct answer to your question, my answer to this question: "What are some empirical technical reasons not to use jQuery?" and other answers and comments there may be interesting for your research as a lot of them talk about performance issues of using and not using JavaScript libraries and frameworks. I hope it helps.

链接地址: http://www.djcxy.com/p/11102.html

上一篇: Datasnap和SocketError

下一篇: JavaScript库的性能开销