Q: Dynamic Load Libraries #Google Sites #DriveApp #UrlFetchApp

Skip to first unread message

Moosy Research

Nov 12, 2020, 7:10:57 PM11/12/20
to Google Apps Script Community
I'm currently using eval and UrlFetchApp to load external libraries dynamically on runtime from a central Google Sites Url.
There are approx. 40 different modules and based on config, the selected module is loaded. (app specific connectors)
This is very efficient and lightning fast!!

The legacy Google Sites will go EOL within a year and the new Google Sites does support public file access anymore. The UrlFetchApp will not work anymore. The suggested alternative is to use use Google Drive and the DriveApp for read the modules from Google Sites.  I don't like DriveApp because it requires additional script authorizations for the end user to their files while this is only to fetch a library from a central url.

As far as I see I have two options:
1. Host my libraries elsewhere and continue using this eval technique 
2. Create a single bulky GAS Library

Do I miss something; is there any other way than eval to load GAS Libraries dynamically on runtime? (consumer version)

Your advise and experience is highly appreciated, 

Adam Morris

Nov 12, 2020, 8:36:50 PM11/12/20
to google-apps-sc...@googlegroups.com
HI there,

I'm curious why you need to do this, but I think the best option for you is to store the code in Github gists. The API for that is pretty straightforward and you can use UrlFetchApp.fetch to interact with it. But you'd have to have your password/token in there somehow.

Anyway, what's the reason for executing library code dynamically?


You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/48eacbc1-ab76-463f-81cf-be4e7e8c7c29o%40googlegroups.com.

Moosy Research

Nov 13, 2020, 2:12:31 AM11/13/20
to google-apps-sc...@googlegroups.com
Thanks Adam,

Definitely a good option for the 'host my libraries elsewhere and continue using this eval technique' option.
I had some hope Google had something to facilitate this without additional license costs.

I have client side code that can run in/with Google Sheets so performance is key.
It uses about 40 pieces of code (Connectors) that are shared across different projects.
These connectors only need to load when configured by the user. Typically up to 3 configured and loaded during initialization. For code maintenance and performance I kept all connectors in separate, external files and did not create one bulky file. The connector code is quit heavy on maintenance so it needs to live external from the client component.

Reply all
Reply to author
0 new messages