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

  • Home
  • SEARCH
  • 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
  • 0 Views
  • 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

I created an Entity Framework model that contains two tables from the Northwind database
I have a Perl script that takes about 30 minutes to run, so of
I arrived at work to today to discover one of our SQL 2005 servers
I need to select the enum values of a column. From searching I've found
i am having a problem with access sql SELECT statement. the problem is that
I have a vb.net app using plain old ado.net to run a s'proc on
this is my first post so if you need clarificatrion on anything then just
Recently I started with developing a JBoss SEAM web application (auction site). So far
I've been scouring every resource I could find, but came up empty. I get

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.