inject external javascript file in google app script(Google Docs) [closed]

Depending on what you mean by Inject, one possible answer is to use the standard javascript eval() function along with UrlFetchApp:

eval(UrlFetchApp.fetch('http://path.to/external/javascript.js').getContentText());

If you want to include a JS file in the HTML output of a published script, simply include the javascript using tags in your HTML.

<script src="http://path.to/external/javascript.js"></script>

Eval docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
UrlfetchApp docs: https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app

Leave a Comment