performance json
Transformation of a big extensive javascript object to a json string can be slow. Working on tomsplanner I found that the generic functions to do such a thing get to slow in IE6. So I wrote a custom stringifier for the tomsplanner json-schema.
The result is that instead of 2413 milliseconds (using json2.js from json.org) it now takes 70 milliseconds to stringify a standard tomsplanner javascript model in IE6. In Firefox it takes 17 miliseconds instead of 1392 miliseconds.
Conclusion: if you work with big javascript objects you want to pass via json and performance is an issue then it really pays off to build your custom stringifier (especially because it is pretty straight forward and easy to do). Note: in tomsplanner the json will be checked for code injection so in my custom version I keep the security checks to a minimum.
The test page can be found here
The result is that instead of 2413 milliseconds (using json2.js from json.org) it now takes 70 milliseconds to stringify a standard tomsplanner javascript model in IE6. In Firefox it takes 17 miliseconds instead of 1392 miliseconds.
Conclusion: if you work with big javascript objects you want to pass via json and performance is an issue then it really pays off to build your custom stringifier (especially because it is pretty straight forward and easy to do). Note: in tomsplanner the json will be checked for code injection so in my custom version I keep the security checks to a minimum.
The test page can be found here
Labels: javascript, json, performance
0 Comments:
Post a Comment
<< Home