Earlier quoted context omitted.
This looks nice. Is it as battle-tested as browserify?
tl;dr—don't use rollup with large untested dependencies I've had projects that got really strange error messages when using rollup that completely went away when I switched back to Babel. One "issue" with rollup is that it is not 100% semantically correct. Neither is Babel in all cases, but the creator argues that if you're not following exact semantics now, you're relying on your tests to ensure proper behavior, so…
Show HN: In-view.js – Get notified when DOM elements enter or exit the viewport
51–60 of 69 posts
Re: Show HN: In-view.js – Get notified when DOM elements enter or exit the viewport
#52A more comprehensive list is here[1], but the main culprits are HTMLElement.offset{Width,Height}, Element.client{Width,Height}, and Window.getComputedStyle(). Avoid these, _especially_ on events like scroll. You will ruin the experience for many of your users.
Re: Show HN: In-view.js – Get notified when DOM elements enter or exit the viewport
#53Whenever you attach an event handler on scroll, it can impact page performance because the javascript needs to be evaluated before the scroll event can continue AFAIK...going from some old Paul Irish talk on performance. The #1 killer he found responsible for "jankiness" (that horrible scroll feeling where the page scroll is unresponsive and not 60 fps smooth) is by people attaching event handlers on the scroll event…
This isn't true no. Scrolling is an asynchronous event, in this case meaning it will happen regardless (without waiting on any JS event handlers), the JS event triggers after its happened. This is the reason you can't prevent scrolling from javascript.
Unlike clicking links, or submitting a form, the browser doesn't wait for any JS event handlers to return before doing this action. This was conscious decision to stop scrolling becoming too heavy or slow, or worse...crashing the page.
Re: Show HN: In-view.js – Get notified when DOM elements enter or exit the viewport
#54I hope this gets used for good, not evil. Lots of sites (you know, those sites, they crop on on HN from time to time) flash up "give me your email address so I can send you spam" boxes before I can read the blog post. Or when it thinks I've gone somewhere else when in fact I just opened it in a new tab. Or if a momentarily switched away. I mostly close blogs that aggressively try to sell me things, but sometimes I wa…
I am using onScreen which I found more efficient than alternative solutions.
Re: Show HN: In-view.js – Get notified when DOM elements enter or exit the viewport
#55Earlier quoted context omitted.
Just use https://www.npmjs.com/package/lodash.throttle
Can you point me to an explanation of the differences between the 'lodash.throttle' module and importing 'lodash/throttle'?
Re: Show HN: In-view.js – Get notified when DOM elements enter or exit the viewport
#56Earlier quoted context omitted.
I hear you. But, isn't this just an editor's draft spec? Only Chrome and Android have done any implementation at all. So, as far as I can tell, there's a chance this will never be fully implemented? And, because it's a draft, the spec could change significantly. Is that right?
A spec being draft seems like an odd reason to ignore it and do a completely different API. Intersection Observer has been implemented in Chrome since 51, and Opera since 38. It's currently being implemented in Firefox ( https://bugzilla.mozilla.org/show_bug.cgi?id=1243846 ), and is "likely" from Edge ( https://developer.microsoft.com/en-us/microsoft-edge/platfor... ). in-view.js's API is certainly less likely to be…
Re: Show HN: In-view.js – Get notified when DOM elements enter or exit the viewport
#57Re: Show HN: In-view.js – Get notified when DOM elements enter or exit the viewport
#58I know that this type of functionality is useful, but please consider the performance implications before doing anything like this. Non-native implementations (i.e. not IntersectionObserver) _always_ use properties and methods that cause style and layout calculations which have a significant performance impact on low-powered devices. A more comprehensive list is here[1], but the main culprits are HTMLElement.offset{W…
some advertising libraries solve that, since the advertising industry deals in in-view ad impressions for a few years now, by being smart about when to do it. the best one is called safeFrames. others like moat detect if the user has a fast computer, abuse it to no end, and then extrapolate the results for the whole audience.
i expect all of them to move to the native APIs soon (but Android fragmentation will make it slow)
Re: Show HN: In-view.js – Get notified when DOM elements enter or exit the viewport
#59Whenever you attach an event handler on scroll, it can impact page performance because the javascript needs to be evaluated before the scroll event can continue AFAIK...going from some old Paul Irish talk on performance. The #1 killer he found responsible for "jankiness" (that horrible scroll feeling where the page scroll is unresponsive and not 60 fps smooth) is by people attaching event handlers on the scroll event…
"Whenever you attach an event handler on scroll, it can impact page performance because the javascript needs to be evaluated before the scroll event can continue AFAIK...going from some old Paul Irish talk on performance." This isn't true no. Scrolling is an asynchronous event, in this case meaning it will happen regardless (without waiting on any JS event handlers), the JS event triggers after its happened. This is…
Re: Show HN: In-view.js – Get notified when DOM elements enter or exit the viewport
#60There is an emerging standard called Intersection Observer that addresses the same use case: https://github.com/WICG/IntersectionObserver/blob/gh-pages/e... This is a really useful problem to solve. But, I would personally prefer to solve it with a polyfill for a standardized approach that will eventually receive native implementation.