Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jstree performance issues

I am using a jsTree with around 1500 nodes, nested to a max of 4 levels (most are only 1 level deep), and I'm getting Internet Explorer's "this script is running slowly" error. I began with just a straight html_data <li> structure, generated by ASP.NET. The tree wouldn't finish loading at all. Then I tried xml_data and json_data, which was a little better but eventually errored out. My last-stitch effort was async loading. This fixed the initial load problem, but now I get IE's error when I expand one of the larger branches.

More details: I'm using the checkbox plugin, and I will also need the ability to search. Unfortunately, when searching, the user could potentially enter as little as one character so I'm looking at some large set of search results.

Has anybody done something similar with such a large data set? Any suggestions on speeding up the jsTree? Or, am I better off exploring other options for my GUI?

I realize I haven't posted any code, but any general techniques/gotcha's are welcome.

like image 493
mike Avatar asked Oct 02 '12 14:10

mike


4 Answers

I haven't completely solved my problem, but I made some improvements so that I think it might be usable (I am still testing). I thought it could be useful for other people:

  • First, I was using jsTree in a jQuery dialog, but that seems to hurt performance. If possible, don't mix large jsTrees and Dialogs.
  • Lazy loading is definitely the way to go with large trees. I tried json_data and xml_data, and they were both easy to implement. They seem to perform about the the same, but that's just based on basic observation.
  • Last, I implemented a poor man's paging. In my server-side JSON request handler, if a node has more than X children, I simply split into many nodes each having a portion of those children. For instance, if node X has say 1000 children, I gave X child nodes X1, X2, X3,..., X10 where X1 has children first 100 children, X2 has next 100 children and so on. This may not make sense for some people since you're modifying the tree structure, but I think it will work for me.
like image 94
mike Avatar answered Nov 01 '22 15:11

mike


jsTree supports all your needs

  • use json_data plugin with ajax support where the brach would be too big.
  • search plugin support ajax call too
like image 24
Radek Avatar answered Nov 01 '22 14:11

Radek


I'm a bit disappointed in it's performance myself.

Sounds like you need to try lazy loading: instead of loading the whole tree all at once, only load as needed.

That is, initially load only the trunk of the tree (so all nodes are "closed"), then only load a node's children when user clicks to open it.

JsTree can do this, see the documentation.

(Is that you mean by "async loading"?)

like image 3
MGOwen Avatar answered Nov 01 '22 14:11

MGOwen


jstree sucks - it is the "refresh" which is slow 10 seconds for a 1000 child nodes being added, or to load a tree with 10000 items among 40 nodes it takes over a minute. after days of development I have told my colleague to look at slickgrid instead, as everyone will refuse to use a page which takes so long to do anything. it is quicker if you do not structure it correctly eg 3 seconds for 1000 nodes but then the arrow will not have any effect to close it down.

This is to replace a combination of ms treeview and ms imagelist which loads the same 10000 items across forty parent nodes in 3 seconds.

like image 1
stuart Avatar answered Nov 01 '22 13:11

stuart