How to read inputs with minimal delay

ok basically im building a script that reads input and have to “make meaning” or the input. now basically im not worried about how to do the implementation, but im worried about how slow or how fast the script may run if i choose the wrong method. which would be preferred?:

  1. read chars 1 by 1
  2. Split that string into multiple sections, which are furthur split into more sections.
  3. a combination of the 2?

I would think that simply reading the value of a field as a whole string would be the fastest method.

You can use the native String method in JavaScript .charAt() to read a particular character in the string (and thus you can use it to iterate over the string and check each individual character).

Do you perhaps have an example / use case to better illustrate your problem?

erm not really. im using the charAt right now, but im worried if there is any performance issues with charAt when the string gets v long. say 15000 chars

If your input expectations are that long, is it really necessary to re-interpret the string character-by-character?

What you’re actually going to do with the string once you’ve read it will affect performance more than the actual string reading.

Performance is also heavily dependent on the browser you’re testing in. For example, a simple array.push() on 1,000,000 characters read in using charAt() in a for look will take approximately 30ms in Chrome, but can take up to 1400ms in IE8 (and about 450ms in Fx 3.6).

Could you perhaps give a use case of how you would need to interpret the string, what sort of things need to be done to it to “make meaning” out of it?