简体   繁体   English

如何在Google Apps脚本Google Docs Extension中包括大型外部样式表和脚本

[英]How to include a large external stylesheet and script in Google Apps Scripts Google Docs Extension

I really want to use Material Design in my new Google Docs extension, but the official library's distribution contains 490 KB of CSS and JS. 我确实想在新的Google Docs扩展程序中使用Material Design,但是官方库的发行版包含490 KB的CSS和JS。 I want my add-on to load fast and work with Docs Offline, as well as not taking too much bandwidth. 我希望我的加载项能够快速加载并与“离线文档”一起使用,并且不占用过多带宽。

Right now, I just have a stylesheet.html and a javascript.html , where I copy-and-pasted the external files and used templating to include them. 现在,我只有一个stylesheet.htmljavascript.html ,我在其中复制并粘贴了外部文件,并使用模板将它们包括在内。 Is there a way where I could support caching or somehow else improve speed? 有什么方法可以支持缓存或以其他方式提高速度吗? Thanks! 谢谢!

Caching frontend script are unavailable on Google Script for Web. 缓存前端脚本在Google Script for Web上不可用。

But you can put script to external HTTPS (not only http!) server and load it as external script – where is possible native caching via HTTP header ( Expires or Cache-Control ). 但是您可以将脚本放入外部HTTPS (不仅是http!)服务器,并将其作为外部脚本加载-可以通过HTTP标头( ExpiresCache-Control )进行本地缓存。

Is you haven't webhosting, you can use Google Cloud Storage. 如果您还没有虚拟主机,则可以使用Google Cloud Storage。 In Google Script editor open Resources > Google Platform project… > click to blue link with project name > hamburger menu > Storage > Browse . 在Google脚本编辑器中,打开资源 > Google平台项目… >单击以带有项目名称的蓝色链接>汉堡菜单> 存储 > 浏览 Here you can create bucket bounded to script's project, upload here any static files and click Share Publicly – you get URL of published script. 在这里,您可以创建绑定到脚本项目的存储桶,在此处上传任何静态文件,然后单击“公开共享” –您将获得已发布脚本的URL。

It is paid service, but price is very optimistics . 它是有偿服务,但是价格非常乐观

Never mind, I just saw that you're not supposed to use Material Design in Google Add-Ons. 没关系,我只是看到您不应该在Google加载项中使用Material Design。 As such, I probably won't load any large external files. 因此,我可能不会加载任何大型外部文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM