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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:44:01+00:00 2026-06-13T04:44:01+00:00

I am trying to improve my knowledge of javascript and while searching for some

  • 0

I am trying to improve my knowledge of javascript and while searching for some “best practices”, someone pointed out to me that it is faster to cache the DOM document and then access it through that var instead of accessing the document object directly.

You can see the results here, on an edit I made on jsperf: http://jsperf.com/jquery-document-cached-vs-uncached/3 (edit: the title holds “jsquery” because that was the original test, my edit contains vanilla javascript, the framework makes no difference)

This really makes me curious. Basically I am introducing a new variable into the equation, how can that make things faster instead of slower?

As far as I know, “print a” should be better than “b = a; print b” (figure of speach)
What’s different in this case?

  • 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-06-13T04:44:02+00:00Added an answer on June 13, 2026 at 4:44 am

    I believe I found an explanation here (the emphasis on the last part is mine):

    Store pointer references to in-browser objects. Use this technique to
    reduce DOM traversal trips by storing references to browser objects
    during instantiation for later usage. For example, if you are not
    expecting your DOM to change you should store a reference to DOM or
    jQuery objects you are going to use when your page is created; if you
    are building a DOM structure such as a dialog window, make sure you
    store a few handy reference to DOM objects inside it during
    instantiation, so you dont need to find the same DOM object over an
    over again when a user clicks on something or drags the dialog
    window.If you haven’t stored a reference to a DOM object, and you need
    to iterate inside a function, you can create a local variable
    containing a reference to that DOM object, this will considerably
    speed up the iteration as the local variable is stored in the most
    accessible part of the stack
    .

    So, if I understand correctly, caching the DOM in a local variable makes it easier to access in the memory stack, therefore increasing the speed of execution.

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

Sidebar

Related Questions

While trying to improve the performance of some OpenCL computation, I used the profiling
I am trying to improve my knowledge on program architecture and recently arised a
Hello I'm trying to improve my ruby knowledge by reading The Ruby Programming Language
I trying to improve a textbox that filters a gridview, by implementing an enhanced
I am trying to improve my C++ by creating a program that will take
I'm trying to improve my jquery/javascript syntax. Is there a better way to write
I am trying to improve my knowledge of OOP in PHP and have been
I am trying improve the fault tolerance in a JSP-page that is updated on
I'm trying to improve the speed of a function that calculates the normalized cross-correlation
I'm trying to improve my build times and want to have some feedback in

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.