views:

44

answers:

1

A lot of my jQuery projects use sub menus. I'm a firm believer of using the hoverIntent plugin over jQuery's native hover(), for usability reasons (and to prevent events being fired by accident by the user).

Because this plugin is used on every page of my site, and because it is only 8 lines minified, I just appended it to the end of my common.js file, which is included on every page. I kept the author comments intact.

The advantage of this is one less HTTP request, for one. It is also common to every page, so it doesn't need to be cache controlled separately.

But, is this good practice? Am I being unethical to the original developer, by lumping his code right at the end?

Should all third party plugins live in their own JS file, and should I leave something like lumping it all together to an automatic minifiying/concatenating process?

Thanks.

+1  A: 

As long as you're keeping the license intact (with where to find the plugin if possible), there's nothing wrong with this...any plugin author should be ok with this in my opinion since this is a purely technical decision.

By combining, you're greatly reducing the HTTP traffic for the user, resulting in a better user experience...the benefits are pretty clear-cut here, and if the following are included, I think you're safe and ethical:

  1. License is intact and complete (as it was in the original plugin)
  2. You're complying with that license
  3. A URL of where the plugin came from, add it if it wasn't in the original IMO.

If it helps, I personally do exactly what you're asking about, all miscellaneous plugins are in one jquery.plugins.misc.js file in my project that gets minified with the rest, larger plugins are by themselves...but they both end up in one larger file compressed by the closure compiler with the licenses intact, and if at all possible, URLs of where to find the plugins.

Nick Craver