1
votes

I have a google apps script deployed as web app. I'm trying to refresh the content by replacing the .innerHTML of some divs with html that is sent back from the server.

For a modest amount of simple html (no more than 3 layers deep, basically 15 grids of 4x21 divs each) it's taking 25 seconds.

I recorded timestamps and found that it acually is the calls to mydiv.innerHTML = newhtml (in the client) that are taking up all that time.

Is this caja sanitation? Reloading the whole page takes about 10 seconds, including at least 4 seconds of server time that I know of. So why is this almost an order of magnitude slower?
Thanks.

1
How much HTML are we talking about here?Mike Samuel

1 Answers

2
votes

It is likely to be caja sanitization, yes. Unfortunately the way it is done on the client involves a slower rewrite than the initial server load. As a short term solution I'd recommend either:

  1. Replacing many innerHtml calls with one call, or
  2. Leaving the HTML structure intact and using textContent instead of innerHTML to change small parts of it (example: leave a table structure intact but not visible, and use textContent on the cells to change the values in it).

In the long term we are aware that this is slow and are actively working on speeding it up. You can ask for more detailed help or follow that progress on the public Caja site.