<?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: Dmytro Zeleniuk</title>
    <description>The latest articles on DEV Community by Dmytro Zeleniuk (@dmytrozeleniuk).</description>
    <link>https://dev.to/dmytrozeleniuk</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%2F4252206%2F36d3ee41-4553-4649-b151-5b6d2b94239a.png</url>
      <title>DEV Community: Dmytro Zeleniuk</title>
      <link>https://dev.to/dmytrozeleniuk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dmytrozeleniuk"/>
    <language>en</language>
    <item>
      <title>How I made a phone animation go from ~35 fps to ~140 fps: draw once, then only move it</title>
      <dc:creator>Dmytro Zeleniuk</dc:creator>
      <pubDate>Wed, 18 Nov 2026 15:33:22 +0000</pubDate>
      <link>https://dev.to/dmytrozeleniuk/how-i-made-a-phone-animation-go-from-35-fps-to-140-fps-draw-once-then-only-move-it-30ll</link>
      <guid>https://dev.to/dmytrozeleniuk/how-i-made-a-phone-animation-go-from-35-fps-to-140-fps-draw-once-then-only-move-it-30ll</guid>
      <description>&lt;p&gt;I build InviteMeOut, an app for invitations and small-business pages that open with an animation: a wax seal that breaks, curtains that part, a towel that wipes dust off a car. The opening is the first thing a guest sees, so it has to be smooth on a three-year-old phone, not just on my laptop.&lt;/p&gt;

&lt;p&gt;One of them wasn't. Here's what was wrong and the rules I follow now.&lt;/p&gt;

&lt;h2&gt;
  
  
  The slow version
&lt;/h2&gt;

&lt;p&gt;The opening for a car-detailing business page wipes a layer of dust off the screen with a towel. The first version did it the "obvious" way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a full-screen SVG mask that grew as the towel moved,&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;feGaussianBlur&lt;/code&gt; and &lt;code&gt;feTurbulence&lt;/code&gt; filters for soft, dusty edges,&lt;/li&gt;
&lt;li&gt;the towel itself as a filtered SVG, animated with SMIL,&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;scale&lt;/code&gt; on the whole layer, and a &lt;code&gt;backdrop-filter: blur()&lt;/code&gt; pill floating on top.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Chrome's phone emulation it ran at about 35 fps. On a real phone it was worse. Every frame the browser had to re-run the filters over the whole screen, re-rasterize the mask, and re-blur whatever sat under the pill.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fast version
&lt;/h2&gt;

&lt;p&gt;Same look, different work per frame:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The dust is a &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; drawn once.&lt;/strong&gt; Each frame only erases the new strip the towel just covered, using &lt;code&gt;globalCompositeOperation = "destination-out"&lt;/code&gt;. Nothing is redrawn from scratch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The towel is rendered once and only moved,&lt;/strong&gt; with &lt;code&gt;transform: translate3d(...)&lt;/code&gt;. The GPU moves a texture it already has.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sheen, glints and dust puffs are &lt;code&gt;transform&lt;/code&gt; + &lt;code&gt;opacity&lt;/code&gt; only.&lt;/strong&gt; These two properties can be animated without layout or repaint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;code&gt;backdrop-filter&lt;/code&gt; element is removed before the animation starts.&lt;/strong&gt; A blur over something that changes every frame is one of the most expensive things you can ask a phone to do.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sizes are in px, not SVG viewBox units,&lt;/strong&gt; so the same towel looks the same on a narrow phone and a wide one.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Result in the same emulation: about 140 fps, and smooth on real phones.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rules I use for every opening now
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Draw heavy textures once (a canvas or a static image), then never redraw them.&lt;/li&gt;
&lt;li&gt;Animate only &lt;code&gt;transform&lt;/code&gt; and &lt;code&gt;opacity&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;No animated masks, filters or &lt;code&gt;background-position&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;No &lt;code&gt;backdrop-filter&lt;/code&gt; over anything that moves.&lt;/li&gt;
&lt;li&gt;Measure before calling it done. I use a tiny &lt;code&gt;requestAnimationFrame&lt;/code&gt; logger that records frame times in phone view:
&lt;/li&gt;
&lt;/ul&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="n"&gt;times&lt;/span&gt; &lt;span class="o"&gt;=&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;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&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="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;tick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;last&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tick&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;avg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"avg fps:"&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="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;avg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"worst frame 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;max&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;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&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;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tick&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;h2&gt;
  
  
  One more thing: sound needs a tap
&lt;/h2&gt;

&lt;p&gt;Phones won't play audio until the user touches the page. Instead of fighting that, the tap that breaks the seal (or starts the wipe) is the same gesture that starts the music. It feels intentional, and it's the only reliable way.&lt;/p&gt;




&lt;p&gt;If you want to see the openings in action, they're at &lt;a href="https://invitemeout.app" rel="noopener noreferrer"&gt;invitemeout.app&lt;/a&gt;. Free on the web and on the iPhone. I'm building it solo, so feedback on what stutters on your phone is very welcome.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>performance</category>
      <category>javascript</category>
      <category>css</category>
    </item>
  </channel>
</rss>
