Search code examples
jsonperformancejspyui

JSP + returning json performance YUI


I have some legacy code that I'm going to tweak. In the jsp there are some calls to server side objects and a big messy block of json is generated server side in the subsequent htm. It is formatted exactly as is below.. please note the large amount of whitespace etc..

This is used by the client side YUI.

I'm assuming this is going to be kinda inefficient. Just wondering if there are any suggestions on improving the performance. Thanks

ListObject.Data = {
items: [










            {itemID:'a',
            itemType:"b",
            displayName:"c",
            description:"Some text",
            feature:"Asdf",

                date:new Date("Feb 24, 2012"),


            savedBy:"",
            release:"",
            override:"",
            name:"bla"}
            ,
                    ****** lots of more elements *******
     ]
}

Solution

  • The only sensible suggestion would be to only send the data you need.

    The next best thing you can do is probably to update to YUI 3.9.1. This version started using native JSON when available and the native version is much faster. See http://jsperf.com/json-native-vs-shim

    And in the realm of crazier ideas, if your JSON content is too large and it's taking too much time to parse, you could parse it in a Web Worker.