Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google apps script - Speeding up getActiveDocument()?

I'm working on a script to set to uppercase a selected text in a Google document. The script works ok, but it is extremely slow in a large document. So I stripped down almost everything to perform some speed test and I realised that this simple line:

      var document = DocumentApp.getActiveDocument();

already takes 9-10 seconds to perform for a 150 pages document.

Is there a way to speed up the process, i.e. precaching "document" so that when I invoke my script I can use my getCursor() or getSelection() in a reasonable time?

like image 447
marcomk Avatar asked Dec 02 '25 12:12

marcomk


1 Answers

You can't precache this. The services provided for caching are:

  • CacheService : only store String values
  • ScriptDB : can't store Document on this.

So I'm afraid that you will need to cope with it.

like image 162
br araujo Avatar answered Dec 06 '25 15:12

br araujo