TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Learning from Twitter

209 点作者 flapjack超过 14 年前

7 条评论

bretthopper超过 14 年前
It's good to know that this situation will lead to improvements in jQuery.<p>However, I'm disappointed in how twitter, or more accurately, Dustin Diaz handled this situation. They identified some performance issues. Narrowed it down to a jQuery version but just left it there.<p>jQuery is open source so they could have done some investigating on their own and tried to narrow down what changed in that selector. Especially since this change was blogged about (as mentioned by John).<p>Not to mention various people helped out twitter by finding some pretty obvious flaws and made suggestions. Twitter has a lot of resources and I'm assuming a lot of talented Javascript engineers. This is a situation where they could have used their resources to contribute to an open source project instead of the other way around.
评论 #2125908 未加载
评论 #2125734 未加载
dionidium超过 14 年前
I use a generic version of the waiting-for-pause trick:<p><pre><code> // execute callback only after a pause in user input; the function returned // can be used to handle an event type that tightly repeats (such as typing // or scrolling events); it will execute the callback only if the given timout // period has passed since the last time the same event fired function createOnPause(callback, timeout, _this) { return function(e) { var _that = this; if (arguments.callee.timer) clearTimeout(arguments.callee.timer); arguments.callee.timer = setTimeout(function() { callback.call(_this || _that, e); }, timeout); } } </code></pre> Use it like this:<p><pre><code> document.addEventListener('scroll', createOnPause(function(e) { // do something interesting here }, 1500, this), false); </code></pre> Edit: Oops! The version in the article runs some code if any scroll event occurred since it last fired, but this one doesn't execute the callback until the user stops scrolling for some amount of time. Anyway, maybe it's still useful for some folks.
评论 #2126887 未加载
评论 #2125879 未加载
eapen超过 14 年前
Why isn't John a billionaire already?
评论 #2125557 未加载
blago超过 14 年前
jQuery makes things almost too easy. As a result it gives confidence and power to a lot of people to write code that despite all sillines will still work. A professional JS developer would've debounced the scroll events and cached the selector results.
评论 #2126039 未加载
评论 #2127040 未加载
cabalamat超过 14 年前
This sort of thing is one reason I hate websites which use a lot of Javascript when they don't need to. Another reason is that it breaks expectations of how websites should work.
评论 #2127310 未加载
btipling超过 14 年前
&#62;since scrolling itself didn't change the DOM<p>Scrolling did indirectly change the DOM as you load more tweets when you scroll. But the point here is that the actual scrolling is not changing the DOM, the append is, and that's probably when you should update your query cache.
评论 #2126206 未加载
Charuru超过 14 年前
What in the world. I expected something interesting, but this is some major fail by twitter. Not caching selectors just boggles my mind. How can a million dollar web company do this?