Search code examples
javascriptcssgoogle-apps-scriptgoogle-drive-apigoogle-sites

Google Apps Script How to link to JS or CSS file on Google Drive


Can I keep style.css or anyscript.js hosted on a folder on Google Drive and then include the script with a link to the file in Drive? If so.. how?

And here I mean GAS for use on Google Sites... so the script is not located in Google Drive


Solution

  • UPDATE: As of August 31, 2015 this technique has been deprecated by Google.

    Google recent made it possible host a file publicly on Google Drive:

    1. Create a folder in Google Drive
    2. Put any files you want to access publicly in the folder
    3. Share it publicly (needs to be "Public on the web") and copy the folder ID from the "Link to Share". For example, the folder ID from this link: https://docs.google.com/folder/d/0B5AR8ct5SZfSTDZTQjNNVXR4RWM/edit ... is: 0B5AR8ct5SZfSTDZTQjNNVXR4RWM
    4. The URL for each file will be https://googledrive.com/host/ followed by the folder id followed by the filename. For example: if you saved style.css in the folder in step #1: https://googledrive.com/host/0B5AR8ct5SZfSTDZTQjNNVXR4RWM/style.css