5

I am building some google apps scripts and want to load a javascript file located on one of my servers and be able to execute it's functions in Google Apps Script.

This way I can share a google apps script with people and update the javascript without effort needed from their side. (I would just update the version on my server which is then loaded in their Google Apps Script.

Is there a way to do this?

Rubén
  • 34,714
  • 9
  • 70
  • 166
Javaaaa
  • 3,788
  • 7
  • 43
  • 54

1 Answers1

14

You can do this:

eval(UrlFetchApp.fetch("my url").getContentText())

Although it would be a lot faster/more efficient to cache the code in CacheService and only fetch it fresh every 15 minutes or so.

TheMaster
  • 45,448
  • 6
  • 62
  • 85
Corey G
  • 7,754
  • 1
  • 28
  • 28
  • 1
    @DanDas This is a significant modification to the original script and answer. I believe it'll benefit from a new answer. I also believe this edit should be rolled back. – TheMaster Apr 30 '23 at 16:07