Update VS 2012 LightSwitch HTML Client to datajs 1.1.1 to utilize JSON-light RRS feed

  • General discussion

  • Hi,

    With the release of datajs 1.1.1, existing LightSwitch HTML Clients can now take advantage of JSON-light format, resulting in smaller amount of data transferred.

    Here's a quick step-by-step to upgrade datajs in your Light Html Client:

    1. In Solution Explorer, select your LightSwitch project, switch to File View.
    2. Right-click on HTML Client project, select 'Manage NuGet Packages'.
    3. Click on Updates on the Manage NuGet Packages dialog.
    4. Select datajs 1.1.1 and Update.
    5. Open default.htm under HTML Client project, and change the reference to datajs-1.1.0.min.js into datajs-1.1.1.min.js
    <script type="text/javascript" src="Scripts/datajs-1.1.1.min.js"></script>

    (If you also want to update LightSwitch JavaScript runtime to 1.0.1, please see this topic to avoid issues later).

    After this, LightSwitch JavaScript Runtime should start using JSON-light for all read requests. For example, here are the requests (with sizes) when loading all 91 Customers from OData Northwind service.

    /NorthwindEntitiesData.svc/Customers?$top=45&$inlinecount=allpages            22.54 KB
    /NorthwindEntitiesData.svc/Customers?$skip=45&$top=45                         22.60 KB
    /NorthwindEntitiesData.svc/Customers?$skip=90&$top=45&$inlinecount=allpages   1.10 KB

    And here are the ones using JSON-light

    /NorthwindEntitiesData.svc/$metadata                                          2.37 KB
    /NorthwindEntitiesData.svc/Customers?$top=45&$inlinecount=allpages            14.11 KB
    /NorthwindEntitiesData.svc/Customers?$skip=45&$top=45                         14.16 KB
    /NorthwindEntitiesData.svc/Customers?$skip=90&$top=45&$inlinecount=allpages   0.92 KB

    Note that with JSON-light we will have one additional request for the Data Service's metadata, this request is only sent once per Data Service. The metadata is then used in all subsequent requests against the same Data Service, so that the server can now skip returning metadata with each individual requests.

    Other than that there should be no changes to the way the data layer works.

    VS 2013 LightSwitch HTML Client will use datajs 1.1.1 when created.

    Best regards,

    Tuesday, September 3, 2013 8:08 PM

All replies