1
votes

I've seen inconsistent load times for Google Apps Script gadgets on my Google Sites. There seem to be two visible phases to the gadget loading process - a "blank" period, and a period with a "loading" animation. Can anyone explain the relationship between these two phases? I suspect but have no way of knowing that my code does not begin to execute until the loading animation is complete. Is this true?

My scripts seem to perform relatively consistently once they reach the loading animation. I have reviewed the available documentation on optimizing performance for Google Apps Scripts, and I have been able to get reasonable load times for my requirements, but the gadget sometimes spends a long time - over 60 seconds - with no content prior to the loading animation appearing.

I have one page with three Google Apps Script gadgets on them, with three very different performance profiles. I am loading data from a spreadsheet in two of them, but I need to iterate through Google Contacts in another which takes quite a bit longer. It appears to me that once one of these scripts hits the "loading" animation, they all begin executing fairly quickly, but nothing I do as a developer influences the time prior to the loading animation.

2

2 Answers

0
votes

Interesting question. But I'm afraid there's really nothing else that we can do. Well, besides complaining with Google :)

I guess you should open an "Enhancement request" on the issue tracker.

1
votes

Web browsers are single threaded when doing server calls in Javascript (or GAS) so it needs to complete all of your function calls to the server before it can return the values from the server and render your page. A workaround would be to create a simple button on the page to start your GAS processes then have a loading screen come up via a clienthandler when the button is pressed. The load screen will be visible as the processes are going on in the background and when you finally finish your processes, you can set the load screen (panel) visibility to false.

Not the most elegant solution, but your initial page will render quickly then you an set a panel (with an animated gif loading graphic if you prefer) to tell the user the page is loading.

Hope this helps!