سؤال

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