Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3437732
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:06:04+00:00 2026-05-18T08:06:04+00:00

I ran the profiler in firebug and found that the most time costly function

  • 0

I ran the profiler in firebug and found that the most time costly function being ran in our UI is jQuery’s .swap(). I can see that this must be associated with the .css() method.

Here is an image of my profiler:

alt text

Obviously, to improve the speed here I need to cut back on calling .css(), but that is quite the project as I use it to set and correct styling of different elements, which has to be completely dynamic.

Is there a better way to speed this up?

I am using jquery.1.4.2. I haven’t been able to move on to 1.4.4 because it breaks quite a few of my scripts for some reason. Would it be be of benefit to extend the swap method from 1.4.4 to 1.4.2? Or would that present more incompatibilities?

What is the swap method and why is it so time costly?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:06:05+00:00Added an answer on May 18, 2026 at 8:06 am

    From what I can see looking at the jQuery UI code, .swap() is not called directly by it, the only place in the jQuery framework itself that uses .swap() directly are the .height() and .width() calls when retrieving the computed height/width of an element.

    What it does to calculate the sizes when not available directly from the browser is temporarily swaps the style out for the following:

    cssShow = { position: "absolute", visibility: "hidden", display: "block" };
    

    Then performs the usual internal getWH() function whilst in that altered style state, and restores.

    The partial code borrowed from jQuery:

    jQuery.each(["height", "width"], function( i, name ) {
        jQuery.cssHooks[ name ] = {
            get: function( elem, computed, extra ) {
                var val;
    
                if ( computed ) {
                    if ( elem.offsetWidth !== 0 ) {
                        val = getWH( elem, name, extra );
    
                    } else {
                        jQuery.swap( elem, cssShow, function() {
                            val = getWH( elem, name, extra );
                        });
                    }
    
                       // etc.
    

    jQuery UI uses height() and width() functions everywhere, so it is little wonder that the .swap() function figures highly in the profile.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: I ran the python profiler and the two most time-consuming things (this is
When I ran the profiler on a JQuery intensive page while tuning for performance,
I ran SQL Server Profiler trace (duration on batch complete) and found one really
I ran my code through xdebug profiler and saw more than 30 percent of
I ran into the problem that my primary key sequence is not in sync
I can't get this working. Here's my code. <script type=text/javascript> function close() { window.opener.location.reload();
How can I make this function more efficient. It's currently running at 6 -
I have a function that writes 3 lines into a empty table like so:
I have stored procedure that insanely times out every single time it's called from
I ran ruby-profiler on one of my programs. I'm trying to figure out what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.