开发者

Is it ineffecient to use a jQuery extension to create your HTML?

I have been using domec. Are plug-ins li开发者_StackOverflow社区ke these much more inefficient than just using jQuery's built in methods?


This depends entirely on HOW you are adding the html. If you are using methods such as .html() or innerHTML that do not manipulate the DOM, these are inherently faster than DOM manipulating functions such as .append(). Each has a different purpose.

To answer your question: yes, it is potentially inefficient to do this. An extension is only going to give you jQuery's native performance AT BEST. The fastest you could achieve would be to write fully optimized javascript.

Your question is analogous to, "Is inefficient to use a PHP framework to generate your webpages compared to compiled C code?"


The goal of products like domec are to make coding easier, not the code more efficient. Look at the source code ... a lot is being done to simply replace a line or two of jquery.


Any time you compromise convenience for efficiency (one way or the other), you're making a choice. If it's worth it or not depends on the application. Sometimes, the environment your application will be executed in has plenty of leeway, and efficiency is just not a concern. Other times, speed is of the essence, and it's worth the developer's time to spend a few extra hours to save the end user a few seconds.

Bottom line, you have to make your own decisions. If performance is an issue, benchmark your code, and use the data you collect decide.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜