slow sorting in firefox (2024)

wcmanes Posts: 19Questions: 1Answers: 0

January 2010 edited January 2010 in General

When pagination is set to show 100 rows, sorting in firefox (3.5) seems very slow. It takes 2-3 seconds for display to refresh. The response time in IE8 and Safari is much quicker (under 1 sec, no real noticeable delay). Stepping through the code in firebug, this is definitely happening in the _fnsort function, but firebug seems unable to step into this procedure.

Multiple users have reported this and it happens in FF with or without firebug enabled/installed. Is there any reason this would be so obviously different in FF only? Is there anything that can be done besides server-side processing? I have less than 200 hundred rows with 7 columns, so it's not really a lot of data. I think it must be a drawing issues as the same number of rows are sorted no matter how many are displayed...

Bill

  • wcmanes Posts: 19Questions: 1Answers: 0

    January 2010

    Oh, one more pertinent piece of information...

    I tried with and without sort classes applied. No apparent change in speed based on this.

  • Hi wcmanes,

    wow - 2-3 seconds to sort on only 200 rows really is slow. I've just tried this in Firefox 3.5 using about 250 records and it appears to work okay with my data set, and basic initialisation. Are you using a complex sorting function or anything like that, or is it as simple as $({selector}).dataTable(); ?

    Are you able to provide a link to the page which is running slow? The _fnSort function will construct a dynamic function to run (unless you are using AIR - which you aren't...) which is why it's harder to debug further down into the sorting. If you wanted to you could force it to use AIR style sorting by doing window.runtime = true, so your profiler will then pick up the sort functions.

    Regards,
    Allan

  • wcmanes Posts: 19Questions: 1Answers: 0

    January 2010

    It's actually just over 100 rows and I'm using standard initialization and sort. Have run firebug profiler and it shows a total time of about 100ms, which doesn't make sense to me (some data below). As I said, I only see the slow response in FF.

    Tried setting window.runtime and I do not see any change. I will send you a PM with a link to the app.

    Profile (107.621ms, 16007 calls)
    _fnDraw129.06%31.271msjquery.d...Tables.js (line 2503)
    remove()95013.85%14.906msjquery-1.3.2.js (line 720)
    add()2377.41%7.977msjquery-1.3.2.js (line 713)
    has()13055.43%5.839msjquery-1.3.2.js (line 730)
    filter()2194.45%4.786msjquery-1.3.2.js (line 1580)
    Sizzle()2193.3%3.548msjquery-1.3.2.js (line 1426)
    find()2183.07%3.305msjquery-1.3.2.js (line 1549)
    inArray()11872.93%3.148msjquery-1.3.2.js (line 1087)
    removeClass()9502.87%3.088msjquery-1.3.2.js (line 1230)
    grep()9502.39%2.571msjquery-1.3.2.js (line 1135)
    (?)()10682.11%2.269msjquery-1.3.2.js (line 723)
    each()4622.09%2.252msjquery-1.3.2.js (line 672)
    isXML()8761.87%2.012msjquery-1.3.2.js (line 2339)
    add()2231.54%1.654msjquery-1.3.2.js (line 712)
    _fnDataToSearch8321.41%1.514msjquery.d...Tables.js (line 3760)
    POS()8341.29%1.383msjquery-1.3.2.js (line 2043)
    _fnBuildSearchArray11.19%1.279msjquery.d...Tables.js (line 3731)
    unique()21.11%1.192msjquery-1.3.2.js (line 1114)
    data()9381.07%1.147msjquery-1.3.2.js (line 1275)

    Thanks for your great work.
    Bill

  • wcmanes Posts: 19Questions: 1Answers: 0

    January 2010

    Did some more debugging. The major issue is related to this code in _fnDraw in the loop through the displayed rows:

    /* Remove any old stripping classes and then add the new one */
    if ( iStrips !== 0 )
    {
    $(nRow).removeClass( oSettings.asStripClasses.join(' ') );
    $(nRow).addClass( oSettings.asStripClasses[ iRowCount % iStrips ] );
    }

    Takes about 900ms for the _fnDraw function with 100 rows displayed.

    I changed this code to:

    (before loop)
    var ia = 0;
    var ir = 1;

    (in loop)
    /* Remove any old stripping classes and then add the new one */
    if ( iStrips !== 0 )
    {
    if ( !$(nRow).hasClass( oSettings.asStripClasses[ia]) ) {
    $(nRow).removeClass( oSettings.asStripClasses[ir] ).addClass( oSettings.asStripClasses[ia] );
    }
    ir = ia;
    ia = 1 - ia;
    }

    This modification reduces the time for _fnDraw to between 100ms and 500ms (depending on how many rows need to have their class updated). This is not as "general purpose" as the original code because it assumes there are always 2 classes (even and odd), which as far as I can tell is always true. It does make a noticeable improvement in the sort response time (from 2-3 sec to 1-2 sec). I think this is acceptable, but it may be able to be improved further.

    Bill

  • allan Posts: 62,305Questions: 1Answers: 10,221 Site admin

    January 2010

    Hi Bill,

    I like it! Nice one - thanks for following up on this. It's given me a few ideas for how to speed the draw up as well, and I'll give them a go, and post back with the results. Certainly your work here is of huge benefit to the project as a whole given how "core" this function is :-) Thanks.

    Regards,
    Allan

  • allan Posts: 62,305Questions: 1Answers: 10,221 Site admin

    January 2010

    Hi Bill,

    A quick update on this - What I've done is basically the same as you've got above, but removed the need for the $().hasClass method call by storing which class is being used for a row in the aoData array. This removes the need for one more DOM interaction, and also one more jQuery call - which should hopefully speed things up just a little bit more :-)

    For a few few quick measurements (Firefox 3.5/Mac with 227 records) I'm getting:

    Old method: 205mS
    New method: 175mS

    So a substantial decrease. I'll looks to see if there are further ways to speed things up a bit - I'm sure there probably are :-)

    Regards and thanks again,
    Allan

  • wcmanes Posts: 19Questions: 1Answers: 0

    January 2010

    Thanks Allan. I would be glad to try out your updates if there is a way I can get your latest code.

    Bill

  • allan Posts: 62,305Questions: 1Answers: 10,221 Site admin

    January 2010

    Hi Bill,

    I've just sent over a copy of the latest development DataTables file. It's got the change in there, so hopefully you'll be able to see a little improvement (although probably not much more than your own method).

    Regards,
    Allan

This discussion has been closed.

slow sorting in firefox (2024)

FAQs

Why is Firefox suddenly so slow? ›

Firefox loads extensions when it starts up and many extensions add startup tasks. If there are too many extensions installed, this may cause Firefox to use more system resources and then slow down Firefox's speed. You can switch to a different theme.

How to fix lag in Firefox? ›

  1. Method 1: Quick Fix Firefox Slow Down by Restarting Firefox.
  2. Method 2: Fix Firefox Slow Down by Clearing Cache Data.
  3. Method 3: Update Firefox to Fix Firefox Speed.
  4. Method 4: Fix Firefox Slow Down by Checking Virus Scan.
  5. Method 5: Hardware Acceleration if Firefox Slow Down.
  6. Method 6: Change Theme to Firefox Speed.
Mar 26, 2024

How do you tell what is slowing down Firefox? ›

Firefox's Task Manager feature lets you see the memory usage and energy impact of tabs and add-ons. This feature can be useful for diagnosing and solving high memory or CPU usage in Firefox.

Will too many bookmarks slow down Firefox? ›

- Too many bookmarks cluttering up your browser can make it slow to load and navigate. - Each bookmark takes up memory, and too many can slow down your browser's processing. - Syncing bookmarks across devices can eat up your internet bandwidth, slowing things down.

How do I clear the cache in Firefox? ›

To clear your cache in Firefox
  1. Click on the menu button. to open the menu panel.
  2. Click History and select Clear Recent History….
  3. Next to Time range to clear, choose Everything from the drop-down menu, select Cache in the items list, make sure other items you want to keep are not selected and then click the OK button.
May 17, 2023

How do I speed up Firefox performance? ›

  1. Update to the latest version. The latest Firefox version may include performance improvements. ...
  2. Restart Firefox. ...
  3. Restart your computer. ...
  4. Disable resource consuming extensions and themes. ...
  5. Hide intrusive content. ...
  6. Use fewer tabs. ...
  7. Close tabs that use too many system resources. ...
  8. Check Firefox hardware acceleration.
Feb 19, 2024

How do I make Firefox more responsive? ›

From the Firefox menu: Select Responsive Design Mode from the Browser Tools submenu in the Firefox Menu (or Tools menu if you display the menu bar or are on macOS). From the Developer Tools toolbox: Press the Responsive Design Mode button in the Toolbox's toolbar.

How do I increase cache in Firefox? ›

disk. capacity (which has a default of 1048576 = 1.048576 GB), then right click > Modify, and enter the maximum size you want in KB, before restarting Firefox again.

Is Chrome slower than Firefox? ›

Edge is about 7% faster than Firefox. Chrome is about 26% faster than Firefox.

How to repair Mozilla Firefox? ›

  1. Restart your computer. Sometimes problems can be fixed by simply restarting your computer and then starting Firefox again.
  2. Clear your cookies and cache. ...
  3. Restart Firefox in Troubleshoot Mode. ...
  4. Reinstall Firefox. ...
  5. Refresh Firefox. ...
  6. Create a new Firefox profile.

How do I refresh Firefox? ›

Refresh Firefox
  1. Click the menu button. ...
  2. Click Refresh Firefox… then Refresh Firefox in the confirmation window that opens. ...
  3. When finished, a window will list your imported information. ...
  4. Select whether you want Firefox to restore all or some windows and tabs and click the Let's go!
Dec 3, 2023

How to fix this page is slowing down in Firefox? ›

Chosen solution

You can extend the hangmonitor wait timeout and create a new Number pref on the about:config page and increase the value from its default of 10000 milliseconds. You can open the about:config page via the location/address bar.

How do I clean up my bookmarks in Firefox? ›

In the left panel, click Bookmarks Menu. In the right panel, click the top item you want to remove, then press Shift+End to select all the way to the bottom, then right-click > Delete.

Can I reinstall Firefox without losing bookmarks? ›

Certain Firefox problems can be solved by performing a Clean reinstall. This means you remove your Firefox program files and then reinstall Firefox. This process does not remove your Firefox profile data (such as bookmarks and passwords), since that information is stored in a different location.

Will I lose bookmarks if I reset Firefox? ›

Although Firefox doesn't delete your bookmarks when you refresh it, your bookmark menu and bookmark toolbar will probably be hidden by default. You would need to Customize Firefox controls, buttons and toolbars in order to see those again.

Why is Firefox lagging randomly? ›

Update your add-ons, and uninstall any you no longer want or need. Add-ons are designed to add features and convenience to Firefox, but out-of-date add-ons can cause errors and lag. Too many add-ons can produce a similar effect.

Why is Firefox crashing so much lately? ›

Mismatched cache and other conflicts of settings can cause Firefox to crash. When Firefox is incorrectly installed, it can also crash from time to time. Broken add-ons and extensions are also a major issue.

Is Firefox slower then Chrome? ›

Edge is about 7% faster than Firefox. Chrome is about 26% faster than Firefox.

References

Top Articles
Latest Posts
Article information

Author: Margart Wisoky

Last Updated:

Views: 6421

Rating: 4.8 / 5 (78 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Margart Wisoky

Birthday: 1993-05-13

Address: 2113 Abernathy Knoll, New Tamerafurt, CT 66893-2169

Phone: +25815234346805

Job: Central Developer

Hobby: Machining, Pottery, Rafting, Cosplaying, Jogging, Taekwondo, Scouting

Introduction: My name is Margart Wisoky, I am a gorgeous, shiny, successful, beautiful, adventurous, excited, pleasant person who loves writing and wants to share my knowledge and understanding with you.