Thursday 15 April 2010

javascript - Which is faster: document.location.pathname or myOwnObj.pathname? -


I am trying to customize my JavaScript code for speed.

I have documents objects that I need to access frequently, such as document.location.pathname or, worse than, Document.documentElement.innerText .

  • Store them as a specialty of one of their objects , So that I can see them as myObj.pathname and myObj.innerText such as

  • While there are some differences in the browser, caching your object makes quick look up.

    The "sharp" object is in comparison with accessing the property twice, instead of once, I actually doubt it is interrupted in your application. In any case, before trying to customize the small things like this, profile it.

  • No comments:

    Post a Comment