This project has moved and is read-only. For the latest updates, please go here.

The HTML version of the TOC is slow in bigger projects

Topics: Developer Forum
Mar 3, 2009 at 9:25 AM
I use SHFB for a project consisting roughly of 10,000 TOC topics. The Index.html has more than 6 MB. Opening the page in a browser from the same machine (http://localhost) takes ~ 30 seconds which is too long for me. The ASPX version loads quickly but one of our publishing targets is a web site where there is no ASP.NET support.

Having a good connection eliminates the problem to transfer quickly the entire TOC. What remains is probably the overhead of the browser which has to build HTML elements for the entire TOC during the page load. I tried to work it around by building the tree structure on demand.

I use XMLHttpRequest to load the TOC to a javascript object and fill the children of a TOC tree node first as it gets expanded. Only the nodes on the root level are expanded at the beginning. It cut the loading time to ~ 2 seconds. I adapted the keyword index to use the same technic and enabled it for the HTML version of the index. It may not be the best solution - I left the single source file of TOC for the simplicity; it could be divided to more parts - but apparently it helps for a middle-sized project.

Leaving the TOC definition in a single file makes the change very small. I modified only TOC.js and added conversion XML -> JSON during the build of the web site target. The TOC.js is usable for both HTML versions having a single bool to switch between them. An additional SHFB plugin makes the Index.html "hollow".

Currently I use the SHFB If you are interested, I will send you the changes or I can apply them to the latest sources. Would you like me to create a work item for it?

Mar 3, 2009 at 4:18 PM
Thanks, that would be great.  I don't think there are any changes between and 1.8.01 with regard to the web files.  You can create a work item and attach your changes to it and I'll merge them into the next release.