1

I have a large JSON object of about 8 MB from a server stored in a browser client. If I cut down the name of variables that are duplicated in these lists will that give a performance boost at all when manipulating the lists and updating the objects?

    { "VenueLocationID" : 12 }

    { "vid" : 12 }
kohane15
  • 809
  • 12
  • 16
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341

1 Answers1

2

If you're transferring 8MB of data from server to client, probably. However, there are better ways to improve performance. If your JSON is coming through an HTTP response, activating gzip compression could net even better performance without reducing readability.

The best way to tune performance is to profile the application -- find out where the bottlenecks are, then address them. Profilers can sometimes find things that I never thought would be issues.

Another thing to look at is how the JSON is being built. I've helped some systems out by stream-parsing. Instead of serializing (stringifying) one huge array, I serialized each element [and wrote it to a response stream,] surrounded by the typical delimiters ('[', ']', and ',').

LexH
  • 1,047
  • 9
  • 21
  • I did that for the actual download, but you guys dont understand after the browser unzips it, its still 8MB in the browser because its the same JSON. – Mike Flynn Sep 10 '18 at 22:04
  • 1
    Actually, this gal understands completely. I suggested the above techniques, because I/O (network, disk) tends to be a bigger bottleneck than RAM. If your client can't fit the object in memory without going to virtual RAM (swap), then [it is also an I/O issue.] – LexH Sep 10 '18 at 22:07
  • We havent had issues with this large object, but I am asking do you get a benefit with having a smaller footprint because of cutting down on naming properties, etc. If not, "IN THE BROWSER", not the http request, which was already done. – Mike Flynn Sep 10 '18 at 22:29
  • Looks like this has already been answered, sorry to waste your time. https://stackoverflow.com/questions/31719887/variable-name-length-vs-performance – Mike Flynn Sep 10 '18 at 22:30
  • Can you answer this one? https://stackoverflow.com/questions/52266089/should-i-destroy-json-object-when-navigating-to-different-page-on-spa – Mike Flynn Sep 10 '18 at 22:34
  • The other answer to which you referred is talking about variables, not properties. [Objects may have different behaviors in RAM, because the interpreter has to keep track of their names as strings.] – LexH Sep 10 '18 at 22:41
  • Well the property stores an object. – Mike Flynn Sep 10 '18 at 22:42