1

I am working on an HTML5/JS text based game, which is single page and uses jquery and handlebars.
What would be the best way to handle the loads of texts that each character and scenario would have? should I store them in separate JSON files and load them on the fly?

Is there a specific way of going about this? or just the jquery's getJson() function?

Thanks!

Baruch
  • 1,618
  • 5
  • 23
  • 42
  • You can store data in localStorage by "JSON.stringify" and get data by "JSON.parse".It can adapt most browsers. – lsv Sep 09 '16 at 04:48
  • Depends on quantity and when you need it. If there's just a little of those, pack it in, no point in a second request. If there's a lot, then how much time do you have till it's needed? If you have a menu, a splash screen, or the like, you can load them asynchronously. If you only need a dynamically-determined subset of the data, load it asynchronously. If you need it right away, deliver with JS. Always think which will inconvenience the user the least. – Amadan Sep 09 '16 at 04:48
  • @Amadan The project will be pretty big, not a simple text based game, so I am planning on a lot of text. I feel like storing all of it in the same js file would get really messy after a while. however, separating it to bunch of small json files and loading them every time feels counter intuitive. lets talk about a scale of 25 npcs, each has a quest line, normal dialog, 4 variations of 400 word long special dialog. should i load everything on launch? or as i go when the character is "approached" – Baruch Sep 09 '16 at 04:51
  • That's not really all that much, given today's computers. Just load it all; allow caching so the user won't have to download it again if they want to play tomorrow. – Amadan Sep 09 '16 at 06:41

0 Answers0