0

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?

rfc1484
  • 9,441
  • 16
  • 72
  • 123
  • 1
    No on both counts, unless it's a ridiculously huge plugin and you're running it on a page where every single millisecond really counts. – James Allardice Jun 12 '12 at 12:25
  • For people who use many, many, many plugins, this might come in handy http://code.google.com/p/minify/ – Joonas Jun 12 '12 at 12:29
  • 1
    If you strip a plug-in of parts, it is no longer that plugin but YOUR plug-in and YOU maintain it. The value of a shared plug-in is also shared effort and maintenance of shared bugs, etc. even if all you do is report the bugs. – Mark Schultheiss Jun 12 '12 at 12:32
  • if it's bad enough that you want to strip the plugin down, consider writing your own JS to do the job instead. right tool for the job and all that. – totallyNotLizards Jun 12 '12 at 13:37

2 Answers2

5

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.

WickyNilliams
  • 5,218
  • 2
  • 31
  • 43
0

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

shershen
  • 9,875
  • 11
  • 39
  • 60
  • good link but that's not what the OP wants. he is asking if it's a good idea to manually edit plugins to strip out features he doesn't need, not how to manage which plugins load. – totallyNotLizards Jun 12 '12 at 13:36