That's a good idea, some are images so they can definitely be stored in flash. Some are constructed from what I read from the SD Card though but they're relatively small. I've also re-written most of the JS to reuse pointers rather than creating new variables.
I like the idea of using an iterator, I was thinking about adding offset parameters to readdir but I think returning and iterator would be better. I'll investigate. Also the ability to get a total count, but that should probably be a separate function call. I like that idea a lot.