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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:59:41+00:00 2026-05-26T06:59:41+00:00

I am just wondering what the pros/cons would be between these two styles of

  • 0

I am just wondering what the pros/cons would be between these two styles of coding:

var foo;
$(document).ready( function() {
    foo = $find(fooID);
});

function OnBarClicked()
{
    foo.doStuff();
    foo.doMoreStuff();
}

compared to

function OnBarClicked()
{
    $find(fooID).doStuff();
    $find(fooID).doMoreStuff();
}

I feel like there’s probably a gotcha in the former, but I’m not aware of why there would be a gotcha. In addition, if there’s any seek time for $find().. is it more efficient to find all variables guaranteed to be ‘found’ 2+ times at the start, and then use the one instance?

EDIT: $find description and usage

var radListBox1ID = "<%= RadListBox1.ClientID %>";
var radListBox = $find(radListBox1ID);
alert(radListBox.get_id()); //Alerts RadListBox1.ClientID
  • 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-26T06:59:41+00:00Added an answer on May 26, 2026 at 6:59 am

    Assuming you’re asking if querying the DOM once vs multiple (one per statement) with $()…

    Yes, it is more efficient to use a single $() and store the result in a variable, rather than invoke jQuery at every statement if you are using the element multiple times within the same scope…

    This is particularly useful in event handlers where you are referencing this as a jQuery object multiple times.

    $('#element').click(function(e) {
        var $clicked = $(this);
    
        $clicked.doStuff();
        $clicked.doMoreStuff();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wondering, having the following simple code: var object1 = { name: function (){
Just wondering if there are pros and cons to methods of password encryption... Typically,
I was just wondering what are the pros and cons of using embedded images
Just wondering what the pros and cons of a TreeSet is, if anyone could
I was just wondering about the pros and cons of submitting metadata and changing
Just wondering if anyone can optimize this usortMonths() function to be better? Basically I
I'm wondering what are the pros/cons of nested dicts versus hashing a tuple in
Just wondering, what would the best way for pulling information from headings in a
just wondering if there is a way to reduce the amount of code needed
Just wondering: I'm trying to set up an adaptive image handler in Coldfusion8, which

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.