Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too many jquery plugins?

I'm developing a website, but I realized that, in addition to the link to my main javascript file, and the link to the jquery file, it's beginning to look like I'm going to have links to three or more plugins also. I'm just wondering if this is good practice? The site I'm building is a web app, so I need a lot of functionality, but I don't want to be a plugin glutton. Is it considered good to append all the javascript plugins together into one file so as to only have to download one file, or will I run into problems?

like image 689
DavidR Avatar asked May 05 '10 12:05

DavidR


2 Answers

If the plugins will be adding value to your site, I cannot see how that will be a problem. In general, plugins contain just enough code to do what they were meant to do. This makes their use quite a good practice when compared to using one monolithic library with plenty of unused functionality.

As for concatenating the JavaScript files together, that can help in terms of front-end loading performance, so I would recommend that.

like image 64
Daniel Vassallo Avatar answered Oct 14 '22 21:10

Daniel Vassallo


Im working on the performance of a large corporate website that uses jQuery. We have found that a high number of connections can really kill performance.

There are three things you can do with your plugins

  1. Minify the javascript using Google Closure Compiler.
  2. Combine the minified js into one download called eg plugins.min.js
  3. Set up an alternate domain for serving js content eg http:/scripts.acme.com.

The minified js means it will download and parse faster, combined into one file will save some connections, and using a cookieless domain will reduce the data that has to be sent up to the server.

Using a CDN eg Google for the main jquery file is also a good idea.

like image 42
James Westgate Avatar answered Oct 14 '22 19:10

James Westgate