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 3487472
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:09:11+00:00 2026-05-18T11:09:11+00:00

I try to do some kind of grid that need to show dot based

  • 0

I try to do some kind of grid that need to show dot based animation in the future.
But it seams to perform pretty slowly even with a few elements (i need to apply it to maybe 5times that many items)

$('div').bind('shrink', function(){
       var $that = $(this).find('> em > span');
       $that.animate({'width': '3px', 'height': '3px'}, 500);
    }).bind('grow', function(){
       var $that = $(this).find('> em > span');
       $that.delay(50).animate({'width': '100%', 'height': '100%'}, 300);
    }).append('<em><span><span><em/>');
//triggering shrink and grow on hover

before starting to do complex animations i wanted to test it with a hover effect.

you can take a look at the demo here:
http://jsfiddle.net/meo/GvfVb/7/

How could i improve the performance of this script?

  • 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-18T11:09:12+00:00Added an answer on May 18, 2026 at 11:09 am

    I seem to get some performance improvements with this version:

    Example: http://jsfiddle.net/patrick_dw/GvfVb/10/

    var shrink = function() {
        $(this).animate({
            'width': '3px',
            'height': '3px'
        }, 500);
    };
    var grow = function() {
        $(this.firstChild.firstChild)
            .delay(50).animate({
            'width': '20px',
            'height': '20px'
        }, 300);
    };
    
    $('div').append('<em><span><span><em/>')
        .find('> em > span').mouseenter( shrink )
        .end().mouseleave(grow)
        .click(function() {
            $(this).unbind('mouseleave', grow);
    });
    

    Here are the changes I made:

    • Changed shrink and grow into named functions, so that .trigger() doesn’t need to be called to fire them, while retaining the ability to remove them by name.
    • Placed the mouseenter event directly on the <span> tag so you don’t need to do a .find() every time mouseenter fires.
    • The mouseleave needs to be on the <div> so I optimized it by removing the .find() and replacing it with a native this.firstChild.firstChild.
    • This was probably the biggest performance improvement: I changed the grow function to animate the width to an absolute value of 20px instead of 100%. Things really smoothed out with that change.

    You could also probably unbind the mouseleave when you click so that it isn’t firing to no effect after the mouseenter has been unbound.

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

Sidebar

Related Questions

I try to create some kind of file browser. I want to know if
I need to display some tabular data in a JSF page. I need some
I was asked to make some kind of reporting (logging) service. The employee has
When I try this code, it starts download but then stuck with alert force
I am thinking to try writing an app that can use android phone to
I've come to the point where I need to store some additional data about
L.S. Excuse me if my english isn't very good. I try to make it
I hava a thread in which I have an infinite loop, doing some network
i'm using the brilliant MediaElement.js library to play video. However, i want to try
I am running OS X 10.6 and using the SVN Applications Versions, and today

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.