Question

Let me start of with outlining the situation. A Standalone HTML5 app indexedDB should get populated with data from a series of XML files (the parsing is nontrivial). The functionality powered by this is non-essential, so the app should be usable before the database is populated. The ideal solution seemed to be to use webworkers, however the DOMParser is unavailable (and the current solution does use functions like querySelectorAll and removeChild to parse the XML).

I will 'answer' my own question below as well, because solutions that do not work for me might work for others. (And hopefully somebody else will be able to suggest a solution that will work for me)

Was it helpful?

Solution

Possible approaches:

  • Browserify JSDOM and use that, although this would theoretically work the generated file is over 29000 lines long... which seems to be unacceptably big even for modern mobile devices or even desktops
  • Do it all whilst the user is using the app in the same thread: slow and makes the app occasionally hang
  • Pre-parse the XML files to JSON and insert those. Seemed to be one of the best solutions, however as I also need the pure XML files in the app itself it would mean passing all the data twice effectively doubling the size of the application.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top