I am developing a small web development application (javascript) for an art project. This is called a "Poetry Generator", and it is a script that generates random verses based on user input.
The script should display a random word to the user every 1/10 of a second. The word list used is 109.582 words.
I have already tried different solutions:
- put all the words in a text file and get a random line of the text file → too slow (and the user needs to download a 3 MB text file before you can use the application).
- put all the words in an array in javascript. → javascript arrays apparently can't handle 109.585 elements
- pull words from a database using the jQuery Ajax function using the Javascript interval function -> this solution worked fine when testing on my local host, but after loading into a real web environment this method turned out to be too slow. (And I could imagine that my hosting provider would not be so happy if every time I made 10 requests to my server.)
So ... Does anyone know of a different approach that I could use to display a random word on a web page every 1/10 of a second? It does not have to use php or javascript, if it works in browsers, I am happy!
Thanks in advance
Teis
Teis source
share