Lighthouseの「合成されていないアニメーション」の直し方
Lighthouse に「合成されていないアニメーションは使用しないでください」(英語の表示では「Avoid non-composited animations」)と出たときは、動かしている CSS プロパティを transform と opacity に置き換えると消えます。CSS アニメーションがスマホでカクつく、ページの表示が少しずれる(CLS が増える)といったときに見る項目です。
検証したページでは、left と box-shadow を動かしていた2つのアニメーションを書き換えると、指摘が消えました。3秒間アニメーションさせたときのスタイルの再計算とレイアウトは、どちらも 180〜181 回から 0 回になりました。
検証環境は Ubuntu 24.04、Node.js 22、Lighthouse 13.6.0(npm のパッケージ)、Chrome for Testing 153、Playwright 1.63.0 です。Lighthouse はコマンドラインから既定の設定(モバイル)で、パフォーマンスのカテゴリーだけを実行しました。ページは同じ VM の中で動かした Node.js の小さなサーバーから配信しました。Chrome の DevTools にある Lighthouse パネル、PageSpeed Insights、Chrome 以外のブラウザ、JavaScript(Web Animations API)で動かすアニメーション、実機のスマホでの見え方は試していません。
指摘が出たページ
検証用に、3つのアニメーションがあるお知らせのページを作りました。
/* 1. 足あとが左から右へ動く(left を動かす) */
.paw { position: absolute; top: 8px; left: 0; width: 32px; height: 32px; border-radius: 50%;
background: #00c8e8; animation: walk 2s linear infinite; }
@keyframes walk { from { left: 0; } to { left: calc(100% - 32px); } }
/* 2. お知らせの帯の色が点滅する(background-color を動かす) */
.notice { margin-top: 16px; padding: 12px; animation: blink 1s ease-in-out infinite alternate; }
@keyframes blink { from { background-color: #ffffff; } to { background-color: #ffd6e0; } }
/* 3. ボタンの影がふくらむ(box-shadow を動かす) */
.cta { /* 色や余白は省略 */ animation: glow 1.5s ease-in-out infinite alternate; }
@keyframes glow { from { box-shadow: 0 0 0 0 rgba(216,88,120,.6); }
to { box-shadow: 0 0 0 12px rgba(216,88,120,0); } }
このページで Lighthouse を実行し、結果の JSON から、この項目の部分を小さなスクリプト(sum.mjs)で抜き出しました。日本語の表示にするため --locale=ja を付けています。
$ npx lighthouse http://localhost:8090/before/ --only-categories=performance --output=json --output=html --output-path=./out/before-ja --chrome-flags="--headless=new --no-sandbox" --quiet --locale=ja
$ node sum.mjs out/before-ja.report.json
lighthouse 13.6.0 formFactor=mobile locale=ja
performance=100 CLS=0.003
non-composited-animations: score=1 mode=informative title="合成されていないアニメーションは使用しないでください" displayValue="2 件のアニメーション要素が見つかりました"
<div class="paw"> selector=body > div.track > div.paw
- サポートされていない CSS プロパティ: left [walk]
<button class="cta" type="button"> selector=body > button.cta
- サポートされていない CSS プロパティ: box-shadow [glow]
指摘されたのは、left を動かす足あとと、box-shadow を動かすボタンの2つでした。background-color を動かすお知らせの帯は、一覧に出ませんでした。3回実行しても、結果は同じでした。
HTML のレポートでは、要素ごとに、合成できなかった理由と、アニメーションの名前(@keyframes の名前)が並びます。

この項目は「診断」のグループに入っていて、パフォーマンスの点数への重みは 0 です。レポートにも「スコアなし」と出ます。検証したページは点数が 100 のままでも、この指摘が出ていました。ただし、公式の解説には、CLS を減らすとパフォーマンスの点数が上がるとも書かれています。アニメーションが CLS を増やしているときは、CLS を通じて点数に関わります。
「合成されていない」とは、メインスレッドで毎回計算しているということ
Chrome は、transform と opacity のアニメーションを、コンポジター(ページの層を重ねて画面を作る仕組み)だけで動かせます。そのほかのプロパティを動かすと、コマごとにメインスレッドでスタイルを計算し直し、プロパティによってはレイアウトもやり直します。web.dev のコンポジターだけで扱えるプロパティについての解説には、コンポジターだけで扱えるのは transform と opacity の2つと書かれています。
これを数字で確かめるため、Playwright でページを開き、Chrome DevTools Protocol の Performance.getMetrics で、3秒間にメインスレッドで行われた処理の回数を数えました(スクリプトは metrics.mjs)。1つのプロパティだけを動かすページを、プロパティごとに作っています。数え方は、ページを開いて1秒待ってから Performance.getMetrics の値を読み、3秒後にもう一度読んで差を取るというものです。
const get = async () => Object.fromEntries((await cdp.send('Performance.getMetrics')).metrics.map(m => [m.name, m.value]));
const a = await get();
await page.waitForTimeout(3000);
const b = await get();
// b.RecalcStyleCount - a.RecalcStyleCount などを出す
single/left.html: RecalcStyleCount=180 LayoutCount=180 RecalcStyleDuration=9.8ms LayoutDuration=8.7ms TaskDuration=64.9ms
single/transform.html: RecalcStyleCount=0 LayoutCount=0 RecalcStyleDuration=0.0ms LayoutDuration=0.0ms TaskDuration=2.4ms
single/box-shadow.html: RecalcStyleCount=180 LayoutCount=0 RecalcStyleDuration=8.1ms LayoutDuration=0.0ms TaskDuration=49.4ms
single/background-color.html: RecalcStyleCount=0 LayoutCount=0 RecalcStyleDuration=0.0ms LayoutDuration=0.0ms TaskDuration=1.9ms
single/opacity.html: RecalcStyleCount=0 LayoutCount=0 RecalcStyleDuration=0.0ms LayoutDuration=0.0ms TaskDuration=2.7ms
| 動かしたプロパティ | スタイルの再計算 | レイアウト | メインスレッドの処理時間 |
|---|---|---|---|
left |
180 回 | 180 回 | 64.9 ms |
box-shadow |
180 回 | 0 回 | 49.4 ms |
transform |
0 回 | 0 回 | 2.4 ms |
opacity |
0 回 | 0 回 | 2.7 ms |
background-color |
0 回 | 0 回 | 1.9 ms |
(3秒間の合計です。180 回は、1秒に 60 回の割合です。)
left は、コマごとにスタイルの再計算とレイアウトの両方が走りました。box-shadow はレイアウトは走りませんが、スタイルの再計算は毎回行われました。transform と opacity はどちらも 0 回でした。
background-color も 0 回で、Lighthouse の指摘にも出ませんでした。Chrome の開発者ブログのハードウェアアクセラレーションによるアニメーションについての記事には、background-color と clip-path を自動でコンポジターで動かす予定と書かれています。
left のアニメーションは、CLS にも数えられていました。直す前のページの CLS は 0.003 で、内訳(layout-shifts)には足あとの要素だけが出ていました。
body > div.track > div.paw score=0.0025
同じ公式の解説には、合成されていないアニメーションは CLS を増やすことがあり、合成されたアニメーションは CLS から除かれる、と書かれています。
left は transform: translateX() に置き換える
足あとを動かすアニメーションは、left の代わりに transform: translateX() で動かします。
元のコードは、left を 0 から calc(100% - 32px) まで動かしていました。この 100% は、線路(親の要素)の幅です。一方、translateX() の % は、既定では動かす要素そのものの幅をもとにします(MDN の left と translateX() の説明)。そこで、足あとを包む .runner の幅を「線路の幅 − 足あとの幅」にしておき、.runner を自分の幅の 100% だけ右へ動かしました。
.runner { position: absolute; top: 8px; left: 0; width: calc(100% - 32px);
animation: walk 2s linear infinite; }
.paw { width: 32px; height: 32px; border-radius: 50%; background: #00c8e8; }
@keyframes walk { from { transform: translateX(0); } to { transform: translateX(100%); } }
<div class="track"><div class="runner"><div class="paw"></div></div></div>
% を使った translateX() でも、Lighthouse の指摘には出ませんでした。いろいろなプロパティを1つずつ動かしたページで試したところ、translateX(50%) を動かす要素は一覧に出ませんでした。前の節の開発者ブログにも、Chromium 89 から、要素の大きさがコマごとに変わらなければ % の transform もコンポジターで動かせると書かれています。
box-shadow は、影の層を重ねて opacity と transform で動かす
box-shadow は、そのままではコンポジターで動きません。そこで、ボタンの後ろにピンクの層を1枚重ね、その層を transform: scale() で広げながら、opacity で薄くしました。
.cta-wrap { position: relative; isolation: isolate; display: inline-block; margin-top: 16px; }
.cta-wrap::before { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 8px;
background: rgba(216,88,120,.6); animation: glow 1.5s ease-in-out infinite alternate; }
@keyframes glow { from { transform: scale(1); opacity: 1; }
to { transform: scale(1.2, 1.5); opacity: 0; } }
.cta { display: block; /* 色や余白は省略 */ }
<span class="cta-wrap"><button class="cta" type="button">予約する</button></span>
ピンクの層を、ボタンそのものの ::before に置かなかったのには理由があります。ボタンに isolation: isolate を付けたうえで、ボタンの ::before に z-index: -1 で置くと、ピンクの層がボタンの背景の上に描かれ、アニメーションの始まりでボタンの色が rgb(6, 122, 152)(元の色)から rgb(132, 102, 133) にくすみました。ボタンを <span> で包み、その <span> の ::before に置くと、ボタンの色は元のままでした。
元の box-shadow の動きとまったく同じにはなりません。影の広がり(12px)は上下左右で同じですが、scale() は大きさの割合で広げるので、横長のボタンでは上下と左右の広がり方がずれます。この検証では、横を 1.2 倍、縦を 1.5 倍にして近づけました。
お知らせの帯の background-color は、指摘が出ていないので、そのままにしました。
直した後の結果
直したページで Lighthouse を3回実行したところ、3回とも項目は該当なし(notApplicable)になり、CLS は 0 になりました。
$ node sum.mjs out/after-r1.json
lighthouse 13.6.0 formFactor=mobile locale=en-US
performance=100 CLS=0.000
non-composited-animations: score=null mode=notApplicable title="Avoid non-composited animations" displayValue=""
ページ全体で3秒間に行われたメインスレッドの処理も、3回とも次のように減りました。
| ページ | スタイルの再計算 | レイアウト | メインスレッドの処理時間 |
|---|---|---|---|
| 直す前 | 180〜181 回 | 180〜181 回 | 67.3〜75.4 ms |
| 直した後 | 0 回 | 0 回 | 2.1〜4.0 ms |
直す前と直した後のページを、アニメーションの開始から 0.5 秒の時点で止めて撮りました。足あとの位置、帯の色、ボタンの後ろのピンクの縁は、ほぼ同じに見えます。

ほかのプロパティで指摘が出るかどうか
left と box-shadow のほかにも、いくつかのプロパティを1つずつ動かして Lighthouse の一覧を見ました。
non-composited-animations: score=1 mode=informative title="Avoid non-composited animations" displayValue="3 animated elements found"
<div class="box c-width" id="width"> selector=body > div#width
- Unsupported CSS Property: width [a-width]
<div class="box c-custom" id="custom"> selector=body > div#custom
- Custom CSS properties cannot be animated on the compositor: --x [a-custom]
<div class="box c-blur" id="blur"> selector=body > div#blur
- Filter-related property may move pixels [a-blur]
| 動かしたもの | 一覧に出たか | 出た理由 |
|---|---|---|
width |
出た | Unsupported CSS Property: width |
@property で登録したカスタムプロパティ --x(transform: translateX(var(--x)) で使う) |
出た | Custom CSS properties cannot be animated on the compositor: --x |
filter: blur() |
出た | Filter-related property may move pixels |
filter: grayscale() |
出なかった | |
transform: translateX(50%) |
出なかった | |
transform: translateX(20px) |
出なかった | |
background-color |
出なかった | |
opacity |
出なかった |
カスタムプロパティは、transform の値の中で使っていても、一覧に出ました。同じ動きを @keyframes の中で transform: translateX(20px) と直接書いた要素は、一覧に出ませんでした。filter は、ぼかしの blur() は一覧に出て、白黒にする grayscale() は出ませんでした。blur() の理由の欄は、日本語の表示では「filter 関連のプロパティはピクセルの移動につながる可能性があります」です。
一覧の理由の欄に出た CSS プロパティの名前が、書き換えるところです。この検証では、位置を動かす left は transform に、影を動かす box-shadow は、層を重ねて transform と opacity で動かす形に書き換えると、指摘が消えました。





