-12

I use htmx which uses this URL for their JavaScript:

https://unpkg.com/[email protected]

This gets rejected, if I try to add it to a runnable stack snippet.

What should I do now?

enter image description here

It gets rejected:

enter image description here

4
  • 7
    That link redirects me to https://unpkg.com/[email protected]/dist/htmx.min.js - does that work for you? Jan 10, 2021 at 19:20
  • @CertainPerformance yes, this works. But wouldn't be nice, if it would work out of the box?
    – guettli
    Jan 10, 2021 at 19:30
  • 5
    How will it know what type of file it is then? It needs to be able to differentiate them because css uses <link> and js uses <script>. Jan 10, 2021 at 22:00
  • @SuperStormer is there no way to auto-detect CSS/JS?
    – guettli
    Jan 11, 2021 at 9:51

1 Answer 1

3

The dialogue you describe is just a shortcut telling the system to add a <script> (or <link>, in the case of css) tag to your snippet- nothing ever stops you from adding one manually that uses a shortened unpkg.com link.

Just make sure you know whether you're adding a css or js file, as pointed out by @SuperStormer.

Eg:

new Vue({
  el: '#app',
  data() {
    return {
      text: 'Hello world!',
    }
  }
})
<script src="https://unpkg.com/vue@2"></script>
<div id="app">
  {{ text }}
</div>

1
  • Thank you very much. How could the first-time-user-experience get improved, to make this more like "don't make me think"?
    – guettli
    Jan 11, 2021 at 19:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .