Search code examples
javascriptgoogle-apps-scriptlibraries

How to load javascript from external source and execute it in Google Apps Script


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?


Solution

  • 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.