Importing the JSZip external library

Lhora Alvarez
Tera Sage

Hi all!

I want to import the JSZip external library by saving its code to a script include.

However, when I tried to run it, an error will appear.

LhoraAlvarez_0-1723686044272.png

Also, I'm not sure if dependencies exist for the JSZip. Can someone tell me if it exists?

I am grateful if you can help me.

 

1 ACCEPTED SOLUTION

Sheldon  Swift
ServiceNow Employee
ServiceNow Employee

It might be possible, but JSZip is primarily used client-side. If you use it server-side, you can only use library functions if they don't rely on any browser-specific features.

View solution in original post

3 REPLIES 3

Sheldon  Swift
ServiceNow Employee
ServiceNow Employee

Hi @Lhora Alvarez - The error you're encountering ("setTimeout" is not defined) indicates that the JSZip library is attempting to use setTimeout, which is a browser-specific function. This function is not available in ServiceNow's server-side JavaScript environment, which is where Script Includes run. I haven't tried it, but I think--at least theoretically--you would use a UI Script.

I see.

Thanks for replying @Sheldon  Swift .

Do I understand correctly that we cannot use the JSZip library in ServiceNow's server-side scripts due to its browser-specific functions?

Sheldon  Swift
ServiceNow Employee
ServiceNow Employee

It might be possible, but JSZip is primarily used client-side. If you use it server-side, you can only use library functions if they don't rely on any browser-specific features.