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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Giving V8 a Heads-Up: Faster JavaScript Startup with Explicit Compile Hints

4 点作者 2freedi26 天前

1 comment

robocat26 天前
For our SPI an important optimisation was to selectively force critical JavaScript to be inline (and avoid script defer or async).<p>The standard browser heuristics were incorrect in our circumstances: which led to suboptimal page loading in the browser (the heuristics slowed down the critical part of page load). To indicate to a browser that JavaScript is on the critical path, you need to use inline scripts. It also required a ton of work to avoid giving the browser a chance to context switch.<p>Part of our loader code would request the same JavaScript from two locations (from both a CDN and from our host) and only evaluate the first response and cancel the redundant request. The JavaScript files were relatively small so the device the browser was running on was rarely bandwidth constrained. The primary reason was to make the page load reliably (files sometimes fail to load - requesting the same file from two locations really upped the reliability. The CDN didn&#x27;t always win the loading latency race for a variety of reasons.<p>There&#x27;s a lot of optimisations that can speed up page load but some require doing what appears odd unless you&#x27;ve very carefully profiled real customer browsers.