If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

and I want to be able to get the data to manipulate it. I can store the file in the same directory as the js, but the only ways I have seen of importing json data into js is with ajax (or the jQuery equivalent), which I kind of want to avoid as I am hoping to make the app offline-capable. I tried with jsonp, but suspect that I don't know what I was doing.

Are there options? It will all be html5, so browser compatibility is not so much of a concern.

i should mention that you can do the same with whatever you use to generate the json in the first place. it writes the files, so just write the callback aorund it at the same time. You can load the file and str.slice(9,-1) to turn the JSONp back into JSON...

i should also mention that you can use ajax offline, i don't see how jsonp is any better than ajax. in fact, it's worse since you don't have a failure event like you do with ajax... Still, both technologies function just fine offline as long as they appear in a correctly-crafted manifest file.

Users who have thanked rnd me for this post:

@ AndrewGSW: seems to work OK, your idea, provided you're grabbing the textContent of the iframe in Chrome and FF. IE wants to download the json file

@ rnd me: I'm not producing the json - that's the problem. I wasn't aware that ajax worked offline, too. thanks for the tip. I'm really quite clueless about the whole offline thing in general. I've looked over the links you posted in this thread and they were very useful. I guess I'll google around for using ajax with manifests, unless you have something handy...?

excellent. as long as it's easy enough to get in and get out of storage (and I'm assuming that 3 minutes googling will give me the answer to that one, unless you have a one-liner up your sleeve...)

And that leads nicely to my next question (I would start another thread, but well, y'know...):

Let's just assume that I know nothing about the cache, local storage, etc. The JSON file can be ridiculously big - nearly 3MB in some cases (which seems quite big, and certainly seems to slow my phone down) but I don't need all of it in one hit. The way I've got it working so far is ajax call dumps all the json into the page then we filter from there, which works fine on the desktop but I guess smaller devices struggle with that load.

What I'm wondering is if:
a) it's possible, and
b) there would be any performance gain

to leaving the json where it is (I'm imagining localStorage here) and only pulling in the bits of data that match the filtering request.

or is it all just one big memory pot, and saving in one place ends up costing somewhere else, making it all balance out in the end?

Let's just assume that I know nothing about the cache, local storage, etc. The JSON file can be ridiculously big - nearly 3MB in some cases (which seems quite big, and certainly seems to slow my phone down) but I don't need all of it in one hit. The way I've got it working so far is ajax call dumps all the json into the page then we filter from there, which works fine on the desktop but I guess smaller devices struggle with that load.

What I'm wondering is if:
a) it's possible, and
b) there would be any performance gain

to leaving the json where it is (I'm imagining localStorage here) and only pulling in the bits of data that match the filtering request.

or is it all just one big memory pot, and saving in one place ends up costing somewhere else, making it all balance out in the end?

localStorage is one big 2.5mb pot. there will be little/no boost from splitting hairs on the client. a performance boost could come from having 30 100kb chunks that are fetched as needed, or a server that feeds the client as needed...

i've loaded json in the 5-15mb range on many devices, and it seems to work. Localstorage will max out in chrome at 2.5mb, since it uses 2bytes per char. ff gives you the full 5, IE has some weird limit that makes no sense, i think it's slightly more than chrome until 10, when it's like firefox's.

depending on your data, you can use deflate to shrink it down 50-75%. some binaries don't like to be zipped, or unzipped rather, but i've had excellent results with ascii text.

manifest is nice because it has no pre-set limit, so it might be all you need.