문제

When using a JQuery plugin, is it a good idea to cut it down in order to only leave the parts necessary for your application or is it better to leave it as it is?

In a related question, is there an impact in performance having to load the entire plugin instead of only the parts you need?

도움이 되었습니까?

해결책

There is always an overhead in loading any code (whether you need it or not):

  • network overhead to download code
  • overhead to parse code
  • overhead to execute additional code paths

However, there is also overhead in stripping down a plugin in that you are basically taking on responsibility for ongoing maintenance and you may introduce bugs inadvertantly.

My advice would be to only use plugins you genuinely need, and to vet the plugins to ensure code quality and that the feature set matches your requirements.

다른 팁

You could use Require.js (http://requirejs.org/) to manage what plugins need to be loaded on each page or event

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top