The example HTML file uses `loadFile()` but gives it an array of multiple file paths to load at the same time:
// Load our files from the brain/ folder.
rs.loadFile([
"brain/begin.rive",
"brain/admin.rive",
"brain/clients.rive",
"brain/eliza.rive",
"brain/myself.rive",
"brain/rpg.rive",
"brain/javascript.rive"
], on_load_success, on_load_error);
Since loadDirectory can’t be used on the web, you have to individually load every file by name; if you add a new .rive file, you have to also add it to that list.
If curious, loadDirectory isn’t supported from a web browser because the environment is different; in the Perl, Python, Java, and (server side, node) JavaScript versions of RiveScript, loadDirectory() works by opening the folder on the local file system and listing the files inside, to find which ones need to be loaded. This is pretty basic in any programming language. But RiveScript.js when run from a browser is in a different environment; it runs inside the end user’s web browser, so it knows nothing about the server’s file system, and it has no way to access the server’s file system. All it can do with the server is make HTTP requests, same as the user could in their own web browser.
The closest analog to trying to scan a directory over HTTP is if the folder path has no index file (so i.e. an Apache web server might respond with “Index of /replies” and list all the entries, for example when you go to http://static.rivescript.com/ ). But, even with directory indexing turned on, the server is technically giving an HTML response full of links and other markup and to try to parse that in the JavaScript… down that way lies madness. It could be programmed to know how to parse Apache’s index page, but then it wouldn’t work on Nginx, and it also would fall apart on any kind of server environment that uses a custom index page template (for example, this site has a custom index template: http://mirrors.liquidweb.com/CentOS/ ).