Created
January 27, 2019 13:42
-
-
Save Richienb/20aa60127cb955d7669a2f6cebcce9ba to your computer and use it in GitHub Desktop.
Load external JavaScript libraries in Google Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load JS from HTML file | |
eval(HtmlService.createTemplateFromFile("<SCRIPT>").getRawContent()) | |
// Load JS from URL | |
eval(UrlFetchApp.fetch("<SCRIPT>").getContentText()) | |
// Load JS from Google Drive | |
eval(DriveApp.getFileById("<SCRIPT>").getBlob().getDataAsString()) | |
// Load JS from URL into global namespace | |
const LIBRARIES = {<SCRIPT REFERENCE>: "<SCRIPT>", <ANOTHER SCRIPT REFERENCE>: "<ANOTHER SCRIPT>"} | |
Object.keys(LIBRARIES).forEach(function(library) { newFunc = eval(UrlFetchApp.fetch(LIBRARIES[library]).getContentText()); eval('var ' + library + ' = ' + newFunc); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment