2

With Google Apps Script, we need to create the HTML and its JavaScript within the Apps Script project itself. I was wondering if there is a way where I can get the HTML from another server?

Basically, the idea is to reuse an existing HTML/JavaScript file which was developed for a non-appscript project and make relevant changes so as to support appsScript.

I don't want my HTML file to be part of the Google Apps Script and instead will be served from an external server. How can this be achieved?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Ekalavya
  • 31
  • 4

1 Answers1

3

You could load the external files using client-side code or server-side code.

  • To use client side code use XMLHttpRequest(), jQuery, <script src="..." />, etc.
  • To use server side code use UrlFetchApp Service to get content from a URL.

Related

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • Thanks for your reply Ruben. Going further, lets say I get my HTML/JS from another server. In the JS file, I might have to call a server-side function which populates a spread-sheet. Ideally, I will have to use google.script.run.functionName(). functionName would have to be in a .gs file in the apps-script project. Right? Can this function or the .gs file also reside in the remote server? Basically, what I am trying to achieve is no code or minimal code to reside in my apps-script project and rest everything should be served from a remote server. Is this possible with apps-script? – Ekalavya Jul 16 '20 at 13:54
  • @Ekalavya What about if you try that and share with us your findings? – Rubén Aug 05 '20 at 16:59