0

I am trying to create new bigger presentation by appending copies of smaller presentations (modules of 3-4 slides). Though I know how to go about doing this, I find the performance to be less than satisfactory. It takes up to 4-5 minutes just to build the final presentation. I am wondering whether there is a way to speed this up. Could someone look at the POC I have so far and point out where I am going wrong? Any help is greatly appreciated!

//This function should run on open of document
function onOpen() {  
 var ui = SlidesApp
 .getUi()
 .createMenu('Modules')
 .addItem('Create new deck...', 'createNewDeck')
 .addToUi();
}

function createNewDeck() {
  var html = HtmlService
  .createHtmlOutputFromFile('Page')
  .setTitle('Training Deck Builder')
  .setWidth(300);
  
  SlidesApp
  .getUi() // Or DocumentApp or FormApp.
  .showSidebar(html);
}

function doSomething() {
  Logger.log('I just did something');
}

function addSlide(id) {
  Logger.log('We are going to add slide number ' + id);
  
  var currentPresentation = SlidesApp.getActivePresentation();
  var newPresentation = SlidesApp
  .openById(id)
  .getSlides();
  
  var slidesLength = newPresentation.length;
  for (var i = 0; i < slidesLength; i++) {
        currentPresentation.appendSlide(newPresentation[i])
      }
}
Hello, world! <br>
<ul>
<strong>Experimentation</strong>
<br>
<input class="slideDeck" type="checkbox" value="1E8hACPZz3HPYinMQgtGz6ijT2GeTTGOkAb44Y64Yepw" />1| Introduction | Intro<br>
<input class="slideDeck" type="checkbox" value="1j4zyaG-66mV5YMrKVi2YHQRvQMAvEXsXv9UqsMSlTqI" />2| Setup | JS Timing<br>
</ul>
<input type="button" id="submitButton" value="Create Slides" onclick="onSubmit()" />

<script>
function onSubmit() {
document.getElementById('submitButton').disabled = true;
try {
var slides = document.getElementsByClassName('slideDeck');
 [].forEach.call(slides, function (slide) {
  console.dir(slide.value);
  google.script.run.addSlide(slide.value);
 });
} catch(e) {
console.log(e);
}

}
</script>
Peter Louis
  • 125
  • 3
  • 11
  • You can check [execution transcript](https://developers.google.com/apps-script/guides/support/troubleshooting#execution_transcript) to find out which part of script is most slow, it will help to narrow answers for your question – Kos Jun 19 '18 at 19:33
  • Although I think that this may be not related to your current issue, it seems that in your script, even if it didn't checked both "checkbox", both values are sent and the active presentation appends them. – Tanaike Jun 19 '18 at 23:25
  • 1
    Hey, did you ever manage to find a solution to speed things up ? I'm running into the same slowness issue – Alb Dum Jul 02 '20 at 09:26

0 Answers0