<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yassine Heddachi</title>
    <description>The latest articles on DEV Community by Yassine Heddachi (@yassine_hed).</description>
    <link>https://dev.to/yassine_hed</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4127807%2F546c36c3-cfb3-4005-b0b7-301c2fddb41b.jpg</url>
      <title>DEV Community: Yassine Heddachi</title>
      <link>https://dev.to/yassine_hed</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yassine_hed"/>
    <language>en</language>
    <item>
      <title>What Browser Game Platforms Get Wrong About Main-Thread Performance</title>
      <dc:creator>Yassine Heddachi</dc:creator>
      <pubDate>Wed, 16 Sep 2026 10:12:38 +0000</pubDate>
      <link>https://dev.to/yassine_hed/what-browser-game-platforms-get-wrong-about-main-thread-performance-nkk</link>
      <guid>https://dev.to/yassine_hed/what-browser-game-platforms-get-wrong-about-main-thread-performance-nkk</guid>
      <description>&lt;p&gt;Browser games are unusual web applications.&lt;/p&gt;

&lt;p&gt;A normal content page might render some text, images, navigation, analytics, and advertising. A game platform has to do all of that while potentially preparing a second application — the game itself.&lt;/p&gt;

&lt;p&gt;That makes main-thread performance especially important.&lt;/p&gt;

&lt;p&gt;While working on &lt;a href="https://ozogames.com/" rel="noopener noreferrer"&gt;OzoGames&lt;/a&gt;, one of the most useful lessons was that performance problems were often not caused by one obviously terrible script.&lt;/p&gt;

&lt;p&gt;They came from &lt;strong&gt;too many reasonable tasks trying to run at the same time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The browser doesn't care that every individual task has a legitimate reason to exist.&lt;/p&gt;

&lt;p&gt;If enough work reaches the main thread simultaneously, the player still experiences a slow page.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Main Thread Is a Shared Resource
&lt;/h2&gt;

&lt;p&gt;JavaScript execution, layout, style calculations, event processing, and many rendering tasks depend on the browser's main thread.&lt;/p&gt;

&lt;p&gt;Imagine the initial page load doing this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;React hydration
Analytics initialization
Ad initialization
Consent management
Recommendation rendering
Thumbnail processing
Game iframe initialization
Game SDK initialization
WebGL startup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Individually, none of these tasks may look disastrous.&lt;/p&gt;

&lt;p&gt;The problem is that the browser receives all of them within the same short period.&lt;/p&gt;

&lt;p&gt;That creates contention.&lt;/p&gt;

&lt;p&gt;A useful way to think about browser performance is not simply:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How expensive is this script?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;but:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What else is happening when this script runs?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Timing matters almost as much as size.&lt;/p&gt;

&lt;h2&gt;
  
  
  A 40 ms Task Can Still Be a Problem
&lt;/h2&gt;

&lt;p&gt;Suppose we inspect a page and see several tasks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;React hydration       42 ms
Ad initialization     38 ms
Analytics             21 ms
Recommendations       47 ms
Game SDK              55 ms
WebGL initialization  63 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;None of those numbers alone looks catastrophic.&lt;/p&gt;

&lt;p&gt;But if the browser processes them almost consecutively, the user may experience a long period where the page feels unresponsive.&lt;/p&gt;

&lt;p&gt;Something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;42 + 38 + 21 + 47 + 55 + 63
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is very different from the same work distributed throughout the user journey.&lt;/p&gt;

&lt;p&gt;That's why optimizing web applications purely by reducing individual bundle sizes can miss the larger problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't Initialize the Product Before the User Wants It
&lt;/h2&gt;

&lt;p&gt;For browser gaming platforms, the game runtime is usually the heaviest application on the page.&lt;/p&gt;

&lt;p&gt;Yet many platforms initialize it immediately.&lt;/p&gt;

&lt;p&gt;That means the browser may be starting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Website application
+
Advertising
+
Analytics
+
Game runtime
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;during the same initial lifecycle.&lt;/p&gt;

&lt;p&gt;A better architecture is often:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Page request
      ↓
Website renders
      ↓
Ads initialize
      ↓
Analytics initializes
      ↓
Player sees game information
      ↓
Player presses Play
      ↓
Game runtime initializes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The total amount of work may be similar.&lt;/p&gt;

&lt;p&gt;The important difference is &lt;strong&gt;when the work happens&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Main-Thread Performance Is About Scheduling
&lt;/h2&gt;

&lt;p&gt;Developers sometimes approach performance by asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What can I delete?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's useful occasionally, but a better question is often:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What can I move?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Consider analytics.&lt;/p&gt;

&lt;p&gt;You probably shouldn't remove your analytics system just because it adds JavaScript.&lt;/p&gt;

&lt;p&gt;Instead, perhaps some secondary analytics logic can initialize after the critical interface becomes interactive.&lt;/p&gt;

&lt;p&gt;The same applies to recommendations, personalization, tracking, and other functionality.&lt;/p&gt;

&lt;p&gt;A rough priority model might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Priority 1
Critical rendering and interaction

Priority 2
Business-critical initialization

Priority 3
Visible secondary UI

Priority 4
Non-critical analytics and enrichment

Priority 5
Heavy functionality triggered by user intent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a game page, the game runtime itself may belong in Priority 5 until the player presses Play.&lt;/p&gt;

&lt;h2&gt;
  
  
  Be Careful With Third-Party Scripts
&lt;/h2&gt;

&lt;p&gt;Browser gaming sites often depend heavily on third-party JavaScript.&lt;/p&gt;

&lt;p&gt;Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;advertising&lt;/li&gt;
&lt;li&gt;analytics&lt;/li&gt;
&lt;li&gt;consent platforms&lt;/li&gt;
&lt;li&gt;authentication&lt;/li&gt;
&lt;li&gt;social widgets&lt;/li&gt;
&lt;li&gt;recommendation services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is tempting to look at a performance report, see a third-party script, and immediately blame it.&lt;/p&gt;

&lt;p&gt;That isn't always useful.&lt;/p&gt;

&lt;p&gt;The better process is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Measure how much main-thread time the script consumes.&lt;/li&gt;
&lt;li&gt;Determine when it executes.&lt;/li&gt;
&lt;li&gt;Identify whether execution blocks critical interaction.&lt;/li&gt;
&lt;li&gt;Check whether the script is business-critical.&lt;/li&gt;
&lt;li&gt;Decide whether initialization can happen later.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Performance work should be based on evidence, not on automatically removing everything Lighthouse highlights.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ads Make Gaming Performance More Complicated
&lt;/h2&gt;

&lt;p&gt;Advertising deserves special attention.&lt;/p&gt;

&lt;p&gt;For many gaming platforms, advertising isn't optional. It funds the product.&lt;/p&gt;

&lt;p&gt;That means the goal cannot simply be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Delay every ad until later
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;because doing so may harm revenue or viewability.&lt;/p&gt;

&lt;p&gt;Instead, the architecture has to separate &lt;strong&gt;game loading&lt;/strong&gt; from &lt;strong&gt;advertising loading&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Initial page lifecycle:

Navigation
Game metadata
Visible content
Advertising
Essential analytics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;After Play:

Game iframe
Game JavaScript
WebGL runtime
Textures
Audio
Game SDKs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This keeps the revenue-critical systems active while preventing the game itself from competing with them unnecessarily.&lt;/p&gt;

&lt;h2&gt;
  
  
  Avoid Layout Work You Don't Need
&lt;/h2&gt;

&lt;p&gt;JavaScript execution isn't the only contributor to main-thread pressure.&lt;/p&gt;

&lt;p&gt;Layout recalculation can also become expensive.&lt;/p&gt;

&lt;p&gt;Suppose a page continuously changes the size of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ad containers
Game containers
Recommendation sections
Images
Navigation elements
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser may repeatedly recalculate layout.&lt;/p&gt;

&lt;p&gt;A gaming page should therefore reserve space for major interface elements whenever possible.&lt;/p&gt;

&lt;p&gt;For example, an ad container should ideally have stable dimensions before the ad arrives.&lt;/p&gt;

&lt;p&gt;Similarly, the game player area should have a predictable aspect ratio.&lt;/p&gt;

&lt;p&gt;CSS can help:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.game-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;aspect-ratio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the browser knows the expected layout before the game loads.&lt;/p&gt;

&lt;p&gt;That helps reduce layout instability and unnecessary recalculation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Watch What Happens After the Play Click
&lt;/h2&gt;

&lt;p&gt;Initial page performance is only half of the problem.&lt;/p&gt;

&lt;p&gt;A browser game can have excellent Core Web Vitals while still providing a terrible experience after the player presses Play.&lt;/p&gt;

&lt;p&gt;Imagine this sequence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Player presses Play

0 ms     iframe created
50 ms    game HTML requested
250 ms   JavaScript downloaded
600 ms   game engine initialization
900 ms   textures requested
1800 ms  WebGL initialization
2400 ms  game becomes usable
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The player waited 2.4 seconds.&lt;/p&gt;

&lt;p&gt;Traditional page-load metrics may not describe this experience very well because the page already loaded long ago.&lt;/p&gt;

&lt;p&gt;That's why browser gaming platforms need their own runtime metrics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a Game Startup Metric
&lt;/h2&gt;

&lt;p&gt;One simple approach is measuring the time between:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;play_click
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;game_start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;playStartedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;onPlayClick&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;playStartedAt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nf"&gt;startGame&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;onGameStarted&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;startupTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;playStartedAt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;trackEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;game_start&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;startup_time_ms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;startupTime&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now instead of guessing how quickly games start, you can measure it.&lt;/p&gt;

&lt;p&gt;You might discover:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Median startup: 820 ms
P75 startup:    1,450 ms
P95 startup:    4,900 ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That immediately tells a more useful story.&lt;/p&gt;

&lt;p&gt;Perhaps most players are fine, but certain games or devices have severe startup problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure the Funnel, Not Just the Page
&lt;/h2&gt;

&lt;p&gt;A browser gaming platform has a natural funnel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;game_page_view
       ↓
play_click
       ↓
game_start
       ↓
fullscreen_start
       ↓
continued_play
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each stage can expose different problems.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;h3&gt;
  
  
  Lots of views, few Play clicks
&lt;/h3&gt;

&lt;p&gt;Possible causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;poor game thumbnail&lt;/li&gt;
&lt;li&gt;confusing interface&lt;/li&gt;
&lt;li&gt;intrusive advertising&lt;/li&gt;
&lt;li&gt;weak game description&lt;/li&gt;
&lt;li&gt;Play button isn't obvious&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Lots of Play clicks, few game starts
&lt;/h3&gt;

&lt;p&gt;Possible causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;game runtime errors&lt;/li&gt;
&lt;li&gt;slow assets&lt;/li&gt;
&lt;li&gt;iframe restrictions&lt;/li&gt;
&lt;li&gt;JavaScript failures&lt;/li&gt;
&lt;li&gt;CDN problems&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Lots of starts, short play sessions
&lt;/h3&gt;

&lt;p&gt;Possible causes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;game quality&lt;/li&gt;
&lt;li&gt;controls&lt;/li&gt;
&lt;li&gt;compatibility&lt;/li&gt;
&lt;li&gt;performance during gameplay&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are product questions that normal page-view analytics cannot answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't Assume Every Game Behaves the Same
&lt;/h2&gt;

&lt;p&gt;One of the challenges of a large browser gaming platform is that games are not uniform.&lt;/p&gt;

&lt;p&gt;Some games may consist of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2 MB JavaScript
3 MB assets
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;while another might require:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;20 MB JavaScript
80 MB textures and audio
WebAssembly
WebGL
Multiple SDKs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A performance strategy that works perfectly for one game can behave very differently for another.&lt;/p&gt;

&lt;p&gt;This is why measuring individual game startup behavior is valuable.&lt;/p&gt;

&lt;p&gt;You can eventually build reports such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Game A
Median startup: 620 ms

Game B
Median startup: 1.1 s

Game C
Median startup: 4.8 s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Game C clearly deserves investigation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preloading Can Help — But Use It Carefully
&lt;/h2&gt;

&lt;p&gt;Once games are deferred until Play, another possibility appears: intelligent preloading.&lt;/p&gt;

&lt;p&gt;For example, if the browser detects strong intent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mouse enters Play button
User focuses game container
Game card remains visible for several seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you might preload selected lightweight resources.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;link&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;preconnect&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://games.example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prepares the connection without downloading the entire game.&lt;/p&gt;

&lt;p&gt;It can reduce startup latency without reintroducing the original problem of loading everything immediately.&lt;/p&gt;

&lt;p&gt;But preloading should be measured carefully.&lt;/p&gt;

&lt;p&gt;If users hover over ten games while browsing, aggressive preloading could create more network waste than it saves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance Optimization Should Protect Product Requirements
&lt;/h2&gt;

&lt;p&gt;A technically perfect Lighthouse score is not necessarily a successful website.&lt;/p&gt;

&lt;p&gt;A gaming platform may need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Ads
Analytics
Recommendations
Accounts
Game tracking
Consent management
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removing all of them would undoubtedly make the page lighter.&lt;/p&gt;

&lt;p&gt;It might also destroy the business.&lt;/p&gt;

&lt;p&gt;Good performance engineering therefore works within product constraints.&lt;/p&gt;

&lt;p&gt;The goal is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make the required systems coexist efficiently.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Delete anything that consumes CPU.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  A Better Debugging Process
&lt;/h2&gt;

&lt;p&gt;When a browser game page feels slow, I like this order of investigation:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Reproduce the problem
&lt;/h3&gt;

&lt;p&gt;Use the same device/network conditions where users experience it.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Record the performance timeline
&lt;/h3&gt;

&lt;p&gt;Look for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;long tasks&lt;/li&gt;
&lt;li&gt;layout recalculation&lt;/li&gt;
&lt;li&gt;script evaluation&lt;/li&gt;
&lt;li&gt;excessive network activity&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Identify the lifecycle stage
&lt;/h3&gt;

&lt;p&gt;Is the problem happening:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before page render?
During hydration?
During advertising initialization?
After Play?
During game runtime?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Measure before changing anything
&lt;/h3&gt;

&lt;p&gt;Record a baseline.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Make one architectural change
&lt;/h3&gt;

&lt;p&gt;Avoid changing ten unrelated things simultaneously.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Measure again
&lt;/h3&gt;

&lt;p&gt;If the improvement isn't measurable, reconsider whether the change was useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Browser Games Need Two Performance Budgets
&lt;/h2&gt;

&lt;p&gt;For a normal site, we often think about a page performance budget.&lt;/p&gt;

&lt;p&gt;For browser games, I think it makes sense to have two.&lt;/p&gt;

&lt;h3&gt;
  
  
  Website budget
&lt;/h3&gt;

&lt;p&gt;Measure things like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;LCP
INP
CLS
JavaScript execution
Main-thread blocking
Initial transferred bytes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Game startup budget
&lt;/h3&gt;

&lt;p&gt;Measure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Play → game request
Play → runtime initialization
Play → first rendered game frame
Play → interactive gameplay
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are different experiences.&lt;/p&gt;

&lt;p&gt;Treating them separately makes optimization much clearer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The main thread isn't slow simply because one script is large.&lt;/p&gt;

&lt;p&gt;Often, the real problem is that too many systems are demanding attention simultaneously.&lt;/p&gt;

&lt;p&gt;Browser game platforms make this especially visible because the site itself and the game runtime are both substantial applications.&lt;/p&gt;

&lt;p&gt;The most effective improvement isn't always:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Make everything smaller.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sometimes it's:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Don't make everything happen at the same time.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Separate initial page rendering from game initialization.&lt;/p&gt;

&lt;p&gt;Measure what happens after the player presses Play.&lt;/p&gt;

&lt;p&gt;Protect business-critical systems such as advertising.&lt;/p&gt;

&lt;p&gt;And optimize based on real performance evidence rather than assumptions.&lt;/p&gt;

&lt;p&gt;Once you start treating &lt;strong&gt;scheduling&lt;/strong&gt; as part of performance engineering, browser game architecture becomes much easier to reason about.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webperf</category>
      <category>webdev</category>
      <category>gamedev</category>
    </item>
  </channel>
</rss>
