Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Some general recommendations:</p> <ul> <li>If you don't want to use jQuery or similar libraries, use a (micro)library of your choice (eg. <a href="http://ajaxian.com/archives/mooajax-13kb-for-all-your-asynchronous-needs" rel="nofollow">moo.ajax</a> (disclaimer: I've never used this, no guarantees, yada yada)) to at least abstract the AJAX request for the textfile. Don't be tempted to think it's trivial to write your own, and have it work cross-browser.</li> <li>If you want to optimize for speed, use a <a href="http://en.wikipedia.org/wiki/Trie" rel="nofollow">trie</a> or similar structure to keep track of the strings. For 10,000 lines with reasonable entropy (ie not completely random data), the memory requirements for this hopefully aren't a problem. You may want to ignore small queries (ie fewer than 3 characters or the like).</li> <li>If you want to optimize for memory usage, only store the list of strings in memory as an array, and use a simple loop and <code>indexOf</code> or regular expression (keep in mind <code>/foo/.test(str)</code> is faster than <code>str.match(/foo/)</code>!) testing to get the list of matching strings.</li> <li>Use innerHTML writing on the select element, and string concatenation to generate the <code>&lt;options&gt;</code>. Manipulating thousands of DOM elements tends to be much slower. Make sure to HTML escape the values, and be aware you may lose selected state (and scroll position) in the list, in case that is important for your application.</li> </ul> <p>Hope that helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload