Hacker News new | ask | show | jobs
by Waterluvian 2121 days ago
How popular is “download this minified file and use it!” Vs. Package management?

I feel like that’s an instant turn off. I don’t want to manually manage all my stuff.

Or is there some middle ground where people just put a URL to the download in their package manager solution, whatever it is.

4 comments

I don't write JavaScript professionally (outside of embedding into C++ applications), but I do make small single-page browser games on my spare time.

I only really use npm packages for Electron; I usually have the libraries locally stored and don't do any soft preprocessing/packaging. Being able to "drop in" the source much like a C/C++ library ends up being comfortable for me for these smaller things. [1]

[1] https://github.com/danbolt/switch-compo/blob/820ce5fb4944e57...

For me, the middle ground is minified/gzipped CDN hosted. Just a simple `<script src="..."></script>` for me.

Presumably you could do that here too, but I don't know how this host feels about hot-linking

You can use jsDelivr:

  <script src="https://cdn.jsdelivr.net/gh/bennettfeely/bennett@master/ztext/js/ztext.min.js"></script>
(You should probably link to a specific commit, though, like:

  <script src="https://cdn.jsdelivr.net/gh/bennettfeely/bennett@24f27b0f902821147ef726735b2717f27335c282/ztext/js/ztext.min.js"></script>
.)
Does npm or whatever package manager is in vogue not have a hack to make a "package" out of a URL pointing to some javascript? (even if someone has to write some automation to package every version from github, as it comes out.)

Although, this point is moot as soon as someone packages it for whatever package manager you use. No matter how hackily they do it. e.g. if there were a npm package called "auto-import-arbitrary-or-versioned-file-from-git-repo-or-http-url" that consolidated _all_ of your random single-file imports, that'd count IMO.

I do this nowadays when the app I'm building isn't too complex yet. I download the latest Preact bundle from unpkg, commit it into git (I know it feels wrong but really, it's fine) maybe add htm and write my stuff as static unprocessed files.

Of course, it's good to have the freedom to go both with and without a package manager and build tools, since this doesn't scale at all.