Access window property from external js library

I am trying to integrate an external js library into ionic 5 and also testing in ionic 4. But, I am not able to access window properties. I get error:

> snapKitInit does not exist in Window & typeof globalThis

I have included the following script tag which loads the js library from inside index.html

      // Load the SDK asynchronously
      (function (d, s, id) {
        var js,
          sjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); = id;
        js.src = "";
        sjs.parentNode.insertBefore(js, sjs);
      })(document, "script", "loginkit-sdk");

In app.component.ts

  doLogin() {
    window.snapKitInit = function () {
            var loginButtonIconId = 'my-login-button-target';
            // Mount Login Button
            snap.loginkit.mountButton(loginButtonIconId, {
              clientId: 'YOUR_CLIENT_ID',
              redirectURI: 'YOUR_REDIRECT_URI',
              scopeList: [
              handleResponseCallback: function() {},