SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    May 2002
    Location
    Montreal
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery UI - find unused functions

    Hello,

    I am currently working on a site that has been created over the years by a variety of contractors and the number of included javascript files has become huge.

    The jquery-ui-1.8.14 file is 190 KB and I would like to clean it up and remove unused functions. Does anyone have suggestions for a way to find them? I could delete them one by one and see if it breaks anything, but the site is quite large and I am not sure where all the pages using jQuery UI are...

    Thanks in advance.

    Mark
    Mark Dixon
    Freelance Web Designer and Developer
    www.markdixon.ca
    Montreal, Quebec, Canada


  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    I'm afraid this might be a little tricky, as in JavaScript you can call functions in some quite dynamic ways.

    E.g. imagine you have this:

    Code JavaScript:
    function  populate_Fields(arg1, arg2){  ... }

    It would be possible to invoke the function like this:

    Code JavaScript:
    var function_prefix = "populate";
    var function_name = "Fields";
    window[function_prefix + '_' + function_name ]("arg1", "arg2");

    Which makes it very hard to find redundant code.

    Saying that though, there are tools like JSCoverage, which generate code coverage statistics showing you which lines of a program have been executed (and which have been missed).
    Maybe that's a good place to start.

    You might also find this discussion helpful:
    http://stackoverflow.com/questions/4...avascript-code


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
  •