Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No global variable to access it when using CDN #6

Open
sandy-yeseul opened this issue Dec 11, 2024 · 2 comments
Open

No global variable to access it when using CDN #6

sandy-yeseul opened this issue Dec 11, 2024 · 2 comments

Comments

@sandy-yeseul
Copy link

Hello,

I'm using this library through CDN since my app is based on pure JavaScript (no node.js)
I'm having problem where I cannot get the global variable that I can access to your library.
Can you teach me how to do it?
below is the code that I'm using

`<script src=" https://cdn.jsdelivr.net/npm/[email protected]/dist/heic-to.min.js "></script>

<script> // none of this works console.log(heicTo) console.log(HEICTo) console.log(heic-to) console.log(heic) </script>

`

thanks!

@hoppergee
Copy link
Owner

Maybe something like this:

<script type="module">
  import {heicTo, isHeic} from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/heic-to.min.js'
  window.heicTo = heicTo
  window.isHeic = isHeic
</script>

Or using importmap

<script type="importmap">
  {
    "imports": {
      "heic-to": "https://cdn.jsdelivr.net/npm/[email protected]/dist/heic-to.min.js"
    }
  }
</script>

<script type="module">
  import {heicTo, isHeic} from 'heic-to';
  
  ...
</script>

Hope it's helpful.

@sandy-yeseul
Copy link
Author

Thank you! I should try to save it to window object. The main script it is using doesn't allow module type so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants