SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jun 2005
    Posts
    260
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Including unused jQuery plugins in main script file slow things down?

    I have a single scripts.js file that houses all my main javascript. At the top of the file I've copy & pasted several jQuery plugins that I frequently use. I've merged everything into one file to achieve download efficiency by preventing multiple header calls.

    Is it bad to include all plugins in the script file the way I'm doing? I don't know the innards of how jQuery works, but do these plugins all have to somehow "register" with jQuery, which can cause a user's browser to bog down while it does this?

    Is it better to just load the plugins as individual, external files on demand using something such as Modernizr.load()?

    Most of the plugins I'm using are pretty lightweight, but a few are quite bulky (FlexSlider).

    Thanks.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,614
    Mentioned
    413 Post(s)
    Tagged
    7 Thread(s)
    Quote Originally Posted by champ View Post
    Is it bad to include all plugins in the script file ... Is it better to just load the plugins as individual, external files on demand ...
    I don't see a problem with this, and it's usually recommended to have fewer rather than more script links. I've not seen jQuery have any issue with plugin scripts included with other scripts. Would be interested to know what experts have to say, though.

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by ralph.m View Post
    I don't see a problem with this, and it's usually recommended to have fewer rather than more script links. I've not seen jQuery have any issue with plugin scripts included with other scripts. Would be interested to know what experts have to say, though.
    For development it's great to have the scripts as separate links.
    When taking things to production, it's best if all of the scripts are combined in to just the one script file.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •