Skip to content
TopicTracker
来自 blog.jim-nielsen.com查看原文
译文语言译文语言

抛弃JavaScript,拥抱HTML

作者在图标网站上重新思考了一个常见交互:之前用Web组件和JavaScript实现图标尺寸切换(sm/md/lg/xl),需要将模板逻辑和数据重复发送到客户端,带来维护负担。如今作者改用纯HTML方案,为每种尺寸单独生成页面(如/colors/red/sm),用户通过导航而非JS进行交互切换。结果不仅代码更简洁,还免费获得了CSS视图过渡动画效果,移动端表现同样出色。这个案例说明:不妨常问自己"能否移除一些客户端JS,获得更好的整体体验?"答案往往是肯定的。

相关报道

  • The article discusses a shift in web development towards using simple HTML for interactivity instead of JavaScript, highlighting how features like the `<details>` element, form-based navigation, and `popover` attributes can reduce complexity and improve performance.

  • The article explores lesser-known features and semantic nuances of HTML list elements (ul, ol, dl), highlighting attributes like reversed, start, and value for ordered lists, and explaining proper use cases for description lists. It emphasizes writing accessible, meaningful markup beyond basic list usage.

  • The article explains how to display fractions in HTML using the `<sup>` (superscript) and `<sub>` (subscript) tags, such as `<sup>1</sup>&frasl;<sub>2</sub>` for 1/2, and notes that CSS styling can improve the appearance of these inline fractions.