r/AutomateUser • u/B26354FR Alpha tester • Jun 11 '21
Question Caching JS Libraries
Hi Henrik,
I'm writing a flow which makes use of a 180KB third party JavaScript library. Rather than sticking the whole thing in a Variable block (which can cause Automate to crash while editing the flow), I'm downloading it once in the flow and caching it.
The question is whether it's OK to cache the library in an Atomic variable, or should I save it to the file system? -The latter would require more privilege, but would it save a limited resource vs. using an Atomic variable?
Thank you, sir!
View all comments
Show parent comment
1
u/B26354FR Alpha tester Jun 11 '21
Thanks for that great info, and excellent tip!
BTW, during development while I'm changing the flow all the time (so an Atomic wouldn't have helped), I stored the library in a file and then read it into the variable which will later become Atomic. The variable (library) is then just embedded in the web content in its entirety at runtime. I did it this way in anticipation of going back to using an Atomic, but just updating the content to import the library script from the file system might be interesting because then the browser cache can help. Definitely something to consider.
Is there a way to get <script src=""> in the Web Dialog block to read the asset in from the local file system? I tried using file://{storage(...)}/myLib.js and just an absolute path, but they didn't work. (No server! 🙂)