|
Post by account_disabled on Jan 24, 2024 23:36:58 GMT -5
本次采访已从Versioning重新发布,Versioning 是 SitePoint 的每日订阅新闻通讯,通过提供前端、后端、设计和用户体验、新闻、业务等方面的要点的精选链接,帮助开发人员了解最新信息和知识。了解更多信息并在此处注册。 注册版本控制 蒂姆·埃夫科 Tim Evko 是一名前端开发人员,主要管理 React 代码库,也是 ExecThread(一家专注于向专业人员提供职位空缺的公司)的团队负责人。当不在 ExecThread 工作时,他将其余时间花在当地的一家健身房,努力成为一名更具竞争力的 Crossfit 运动员。 目前哪种技术理念或趋势最让您兴奋? 最近,我对Service Worker 技术着迷,尤其是用于帮助网站快速加载并快速交互时。我喜欢性能和网络应用程序离线功能,并且我认为社区可以从对构建弹性、多功能和快速应用程序的更多关注中受益。 与 Service Worker 一起工作特别有趣,因为你可以用他们做很多事情在浏览器中的选项卡之间进行通信,从而允许每个单独的选项卡在缓存过时时重新加载自身。 这不是一项容易使用的技术,但我很高兴它的存在! 我想我以前没有听说过这个——你能说得更详细吗? 在浏览器中,Service Workers 可以控制可用范围内的所有客户端,而不仅仅是当前活动的选项卡。这意味着当 Service Worker 与浏览器中的站点通信时,它仍将与当前显示该站点的所有 WhatsApp 号码数据 选项卡进行通信。当使用 Service Worker 附带的 postMessage API 时,您可以利用此功能。 可以在此处找到详细示例。在 ExecThread,我们使用此功能重新加载所有选项卡,以防 Service Worker 将旧 CSS 文件提供给带有新标记的页面。 描述(或链接到!)您最近构建、设计或生产的一些很酷的东西。你为什么以此为荣? 我最近开始了解虚拟 DOM 算法的工作原理,并在此过程中构建了我自己的组件渲染器 实际上非常简单,这就是我喜欢它的原因。如果您给它一个节点(例如页面上的 div)和 ES6 模板字符串,它将更新第一个 div,使其与模板字符串匹配。本质上,它是一个 DOM 比较函数,确保其目标看起来像模板字符串。 然而,由于它是 ES6 模板字符串,因此您可以向比较添加逻辑。这意味着每当您更新逻辑所基于的任何状态时,您都可以调用 diffing 函数,并且您的原始 DOM 目标将与新状态匹配。整个过程的工作原理是使用模板字符串创建一个不可见元素,然后比较目标元素(及其子元素)以查找、删除或修改所有 DOM 节点,直到基于模板字符串的元素和目标元素看起来相同。 它很高效,因为它永远不会更新不需要更新的元素,从而防止浏览器执行不必要的工作。如果您有 100 个嵌套元素,并且其中之一只更改了一个类名称,BadDom 将找到该元素并仅更改该类。 你是如何建造它的? 像我的大多数项目一样,我在 CodePen 上构建了这个项目。我喜欢专注于使用尽可能少的构建工具/设置来使事情尽可能简单。这样,任何人都可以最容易地理解并做的工作中学到了多少东西,但我只想说每个人都应该自己看看。 我喜欢使用模块模式编写所有 JavaScript,我在这里就是这么做的。模块模式是一种编写 JavaScript 的方法,以便所有代码都位于自包含对象内。
|
|