Htmx 2.0.0 已发布
Htmx 2.0.0 has been released

原始链接: https://htmx.org/posts/2024-06-17-htmx-2-0-0-is-released/

HTMX 2.0 发布,在保持核心功能的同时引入了多项更改。 总结如下: 1. **浏览器兼容性:** 不再支持 Internet Explorer。 2. **扩展:** 从核心存储库移至 https://extensions.htmx.org 上的各个扩展存储库。 他们可以独立开发,不会影响 htmx 的发布时间表。 3. **上证分机:** 旧的坏了; 需要升级才能继续使用。 4. **HTTP DELETE 请求:** 现在根据规范使用查询参数而不是表单数据。 5. **JavaScript 模块样式:** 在 /dist 文件夹中为不同模块类型添加了单独的文件 – ESM、UMD、AMD。 6. **已弃用的属性删除:** 用扩展替换了 hx-sse 和 hx-ws。 7. **默认更改:** 将 htmx.config.scrollBehavior 更改为“即时”,并将 htmx.config.selfRequestsOnly 设置为 true。 8. **API 方法更改:** 将 selectAndSwap() 替换为 public swap()。 9. **Web 组件支持:** 大幅改进。 10. **深色模式功能:** 网站添加了对深色模式的支持。 对于那些需要 IE 兼容性的人来说,htmx 1.x 仍然是一个选择。 要安装 HTMX 2.0,请选择包管理器或从 CDN 下载。 For detailed migration instructions, consult the official HTMX 1.x -> 2.x Migration Guide.

一个团队考虑向 HTML 添加 TreeView 组件以改善开发人员体验和效率,但由于潜在的实施时间和财务影响而面临反对。 相反,他们专注于使用 Rust 语言和相关工具增强现有的 Web 应用程序,例如用于 Web 应用程序的 axum、用于交互的 axum-htmx、用于数据库访问的 rusqlite 以及用于 HTML 模板的 Maud。 他们利用 htmx 通过 HTTP 请求动态加载组件,从而提高性能和用户交互性,而无需对前端代码进行重大更改。 他们更喜欢 Maud,而不是流行的替代方案,因为它易于编写标记和测试功能,为各个页面部分维护单独的模板,并根据请求处理端点以服务这些部分。 端点 URL 遵循域/页面/部分格式,确保正确路由,同时返回带有更新数据的渲染模板。 最终,他们的重点仍然是 Rust 后端和高效的资源利用,而不是在 Web 标准中纳入额外的树视图功能。
相关文章

原文

I’m very happy to announce the release of htmx 2.0. This release ends support for Internet Explorer and tightens up some defaults, but does not change most of the core functionality or the core API of the library.

Note that we are not marking 2.0 as latest in NPM because we do not want to force-upgrade users who are relying on non-versioned CDN URLs for htmx. Instead, 1.x will remain latest and the 2.0 line will remain next until Jan 1, 2025. The website, however, will reference 2.0.

Major Changes

  • All extensions have been moved out of the core repository to their own repo and website: https://extensions.htmx.org. They are now all versioned individually and can be developed outside of the normal (slow) htmx release cadence.
    • Most 1.x extensions will work with 2.x, however the SSE extension did have a break and must be upgraded.
    • The older extensions remain in the /dist/ext directory so as to not break the URLs of CDNs like unpkg, but please move to the new extension URLs going forward
  • We removed the deprecated hx-sse and hx-ws attributes in favor of the extensions, which were available and recommended in 1.x.
  • HTTP DELETE requests now use parameters, rather than form encoded bodies, for their payload (This is in accordance w/ the spec.)
  • We now provide specific files in /dist for the various JavaScript module styles:
    • ESM Modules: /dist/htmx.esm.js
    • UMD Modules: /dist/htmx.umd.js
    • AMD Modules: /dist/htmx.amd.js
    • The /dist/htmx.js file continues to be browser-loadable
  • The hx-on attribute, with its special syntax, has been removed in favor of the less-hacky hx-on: syntax.

Minor Changes

  • We made some default changes:
    • htmx.config.scrollBehavior was changed to 'instant' from 'smooth'
    • As mentioned previously, DELETE requests now use query parameters, rather than a form-encoded body. This can be reverted by setting htmx.methodsThatUseUrlParams to the value ['get'],
    • htmx.config.selfRequestsOnly now defaults to true rather than false

Features

Not much, really:

  • The selectAndSwap() internal API method was replaced with the public (and much better) swap() method
  • Web Component support has been improved dramatically
  • And the biggest feature of this release: the website now supports dark mode! (Thanks @pokonski!)

A complete upgrade guide can be found here:

htmx 1.x -> 2.x Migration Guide

If you require IE compatibility, the 1.x will continue to be supported for the foreseeable future.

Installing

htmx 2.0 can be installed via a package manager referencing version 2.0.0, or can be linked via a CDN:

<script src="https://unpkg.com/[email protected]/dist/htmx.min.js"></script>

or Downloaded

联系我们 contact @ memedata.com