function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pradeep BandarpalliPradeep Bandarpalli 

Issue with loading/using external javascript static resource in Lightning component when Locker service is Enabled

Hi,
My requirement is to zip the content in client side controller using javascript library JSZIP, i have included it as a static resource. Below is the code. 

Component:
<aura:component >
    
    <ltng:require scripts="/resource/jszip" />
    
    <ui:button label="Press" press="{!c.onPress}" />
    
</aura:component>

Controller: 
({
onPress : function(component) {
        var packageXml = '<?xml version="1.0" encoding="UTF-8"?>' + 
            '<Package xmlns="http://soap.sforce.com/2006/04/metadata">' +
            '<version>35.0</version>' +
            '</Package>' ;
        
        zipFile = new JSZip();
        zipFile.file('package.xml',packageXml,{base64: 'true'});
        var data = zipFile.generate();
        alert(data);
}
})

I click on Press button, while locker service is enabled I am facing issue and when Locker service disabled the alert is showed as expected (attached the outputs).

Locker service enabled:
When locker service enabled

Locker service disabled:
When locker service disabled
Thank you for help.