(评论)
(comments)
原始链接: https://news.ycombinator.com/item?id=39429370
关于使用 URL 片段作为链接目标导致历史导航损坏的担忧,这里有几点:
1. 确实,传统的URL片段不会更新地址栏中的URL。 然而,正如评论中作者注释中所解释的,该技术为每个加载的组件使用 IFRAME,从而有效地创建单页应用程序 (SPA)。 这种类型的架构无需在每次显示新组件时完全重建 UI,从而实现与 ReactJS、AngularJS 和类似库流行的单页应用程序架构模式相当的近乎即时的加载时间。 如前所述,本文中介绍的 htmx 和 HTMZ 技术提供了一种替代方案,无需安装庞大的前端框架即可提供这些优势。
关于与 HTMX 的比较,此实现的不同之处主要在于它对普通 HTML 的依赖,正如作者本人在回应上述评论时所描述的那样。 据他介绍,这允许使用更轻量级的 HTML 代码,而 HTMX 使用与渲染的 HTML 一起运行的脚本来转换特定的 DOM 元素。 此外,虽然 htmx 广泛使用客户端脚本,但当前的实现演示了如何纯粹通过 HTML 和浏览器的固有功能来实现这些功能。 最终,这种差异取决于个人偏好,即更精简、更干净的客户端体验与 HTMX 语法糖和随附的开发人员工具提供的便利性之间的差异。
总体而言,所提出的解决方案提供了优雅与实用的独特结合。 虽然它可能不适合每个人的口味或环境,但它确实可以作为一个很好的概念验证和示例,说明仅通过本机网络技术即可实现什么。 此外,通过严格遵守网络标准并避免过于复杂或晦涩的概念,这种方法最终简化了任何希望学习或掌握这些概念的人的整体学习曲线。 无论您是喜欢 Vue.js 还是完全避免额外的复杂性,本文中演示的方法都会令人耳目一新,提醒您接受 Web 标准带来的限制以提供高效的解决方案,同时保持可读性和可维护性通常是值得的。 总之,本文中采用的技术代表了网络技术创新的一个令人着迷的例子,为更大、更笨重的前端提供了可行的替代方案
A reminder to never give up good ideas, focus on excellence, and focus on refinement to a completion of an idea, and communicate well!
Also the comments here:
- This is a great hack and shows how close the browser is to offering SPA natively.
- This is a glorious demonstration of someone really understanding the platform.
- Simple and powerful, as the vanilla web should be. Thank you for this (small) gem :)
- This is a neat hack, I like it :). Thanks for sharing.
are exactly what I hoped to hear reflected about my creation, and are totally on point for what this type of thing should be. Close to the web-grain, using the given material of the web in the best way possible. Fuck yeah! :)
Thank you for being a genius! :)
And for inspiring about what's possible! :)
P.S - also your communication and marketing skills are top notch! I think the way you have communicated this elegant technical thing, from the choice of name, API, examples, copy -- is just awesome. I learn from it! :)
reply