TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The Import on Interaction Pattern

46 pointsby pspeter3over 4 years ago

6 comments

jkcxnover 4 years ago
&gt; Rather than eagerly loading the react-scroll dependency for this, they load it on interaction with the button, saving ~7KB:<p>My apologies for being negative but isn&#x27;t it crazy it takes 7KB to scroll to the top of the page?
评论 #25371344 未加载
评论 #25366674 未加载
lhorieover 4 years ago
Funny how we keep coming back full circle. A common optimization trick back in the day was to use pjax&#x2F;turbolinks to achieve exactly this pattern. You could even go one step further and start loading on mouseover, rather than on click, giving you upwards of a one second head start.
red_admiralover 4 years ago
I&#x27;m in two minds about this.<p>In favour: TTI and similar metrics are really important, not just for SEO but because Google and friends base these metrics off actual user behaviour: if your page takes to long to load, users will go elsewhere. Lazy-loading for features that are rarely used (and you&#x27;ve actually done the analytics to justify this) can be a valid trade-off.<p>Against: this behaviour in some form has made it even into Microsoft Word. Click the &quot;select font&quot; dropdown and it can freeze for a couple of seconds to create the list, especially if you have a big document open. The same, if you&#x27;re unlucky, for the styles dropdown, the &quot;insert special character&quot; button because it insists on showing you the most-recently-used ones in a menu it has to build on click (as well as in the dialog box), and a few other places.<p>I expect better than this from a desktop application, especially as I remember these things being almost instant back around WinXP days. Sure it didn&#x27;t come with Bing integration, but I can live without that.<p>And web sites and applications should aim to emulate the responsiveness that we used to have on the desktop.
jiofihover 4 years ago
Back then we used to have <i>index.js, chat.js, checkout.js</i>, and so on.. even your grandma’s website had free “code splitting” and “dynamic imports”!
superjanover 4 years ago
Good advice. But really why do you need 500k extra javascript to play a video?
terryfover 4 years ago
Please don&#x27;t - too many times have I loaded a number of tabs containing medium posts before stepping on a flight with no wifi and only then discovering that images a page down are not visible.<p>It&#x27;s fine to not load everything immediately, but load the page and then start loading all the resources, but don&#x27;t wait until I scroll to the right place!