by beauHD · 3y ago · 0 comments
HTMLX is great and all, but loading it from a CDN is insecure and wrought with problems. Namely, the JS file in question could be hijacked and replaced with a malicious version that can steal data. It's unlikely, but still a plausible scenario. Also: the resource could just 404 and not be available due to work-in-progress scenarios on the CDN side.
I would much rather host it on my own domain that I control.
<script
src="https://example.com/example-framework.js"
integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"
crossorigin="anonymous"></script>And then it says in the docs right after:
> While the CDN approach is extremely simple, you may want to consider not using CDNs in production.
> The next easiest way to install htmx is to simply copy it into your project.
> Download htmx.min.js from unpkg.com and add it to the appropriate directory in your project and include it where necessary with a <script> tag:
Someone else in the thread was asking about webpack. webpack. What has javascript done to people's expectations?
You can ensure you're always running the version of the script you validated, assuming you even validate the code (which presumably no one does).
You can and they encourage users to consider not using CDNs in production