Ha, Nathan and I were talking about this but for the spans containing the text to type. We didn't think it would work because the spans' contents are constantly changing. But I think I see what you mean - store the element itself in a var not the element's contents, right?


Sent from my iPhone

On Sep 26, 2013, at 7:54 PM, Zee <notifications@github.com> wrote:

> In public/user_feedback.js:
> 
> > @@ -47,5 +37,29 @@ function ShiftWords(){
> >        strings.future_text = strings.future_text.substring(i+1,strings.future_text.length);
> >      }
> >    };
> > +  this.evaluate = function(){
> > +    if (that.compareText(strings.current_word)){
> > +      if(that.shift() === false){
> > +        that.updateDom()
> > +        return false
> > +      }
> > +      that.updateDom()
> > +    }
> > +  };
> > +  this.compareText = function(word){
> > +    var inputText = document.getElementById('inputBox').value;
> Since we keep getting the inputBox from the DOM, what if we saved it as an attribute on the stringHandler, so other methods could access it?
> 
> Think of every time you select something from the DOM, either by getElementById or querySelectorAll or whatever, it's doing a select on a database. If you run it once and assign it to a variable, then you can just access the element over and over without querying the DOM. This is a concept known as caching and it's a fun problem :).
> 
> —
> Reply to this email directly or view it on GitHub.