如何从外部来源加载JavaScript并在Google Apps脚本中执行 [英] How to load javascript from external source and execute it in Google Apps Script

查看:96
本文介绍了如何从外部来源加载JavaScript并在Google Apps脚本中执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一些Google应用程序脚本,并希望加载位于我的一台服务器上的JavaScript文件,并且能够在Google Apps脚本中执行它的功能。

通过这种方式,我可以与人分享Google应用程序脚本,并在不需要从他们身边所需的情况下更新javascript。 (我只是更新我的服务器上的版本,然后加载到他们的Google Apps脚本中。



有没有办法做到这一点?

$ b $您可以这样做:

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

虽然它会快很多/更高效地将代码缓存在ScriptDb或CacheService中,并且每隔15分钟左右就可以获取一次。


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?

解决方案

You can do this:

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

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

这篇关于如何从外部来源加载JavaScript并在Google Apps脚本中执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆