Is there data size limit for attributes? (persist data)

Talk about add-ons and extension development.
Post Reply
User avatar
Vano
Posts: 403
Joined: December 26th, 2007, 8:21 pm

Is there data size limit for attributes? (persist data)

Post by Vano »

Hello.

I couldn't find any information regarding data size limit for attributes, is there any and if so what is it?

I'm saving an array of user keywords in json format in a persist attribute of xul element, and worry that in time as the array grows if there is a limit and part of it will be lost, it will break json...

Thanks.
lithopsian
Posts: 3664
Joined: September 15th, 2010, 9:03 am

Re: Is there data size limit for attributes? (persist data)

Post by lithopsian »

Not what attributes are for ;)

I don't think there is a set limit, but very long attributes will dramatically degrade performance to the point where scripts may hang, or even the whole browser. Probably you won't go to such lengths (sic), but its one of those "if everyone did it" things. A megabyte attribute might work fine, but if five different addons all did it then Firefox would crash,

Persisting attributes is also tricky stuff, not intended for high reliability and liable to disappear at any moment, although in practice it tends to persist longer than you'd like. Depending on your particular use, consider a preference (for a few hundred bytes), the simple storage module (I don't like it for several reasons, but it is synchronous and "simple"), the similar WebExtensions storage API, Moz storage (SQL, for structured data), IndexedDB (more powerful, but less easy to use), or dedicated files (can do anything you want, but you're on your own).
Post Reply