aboutsummaryrefslogtreecommitdiff
path: root/files/de/tools/paint_flashing_tool
diff options
context:
space:
mode:
Diffstat (limited to 'files/de/tools/paint_flashing_tool')
-rw-r--r--files/de/tools/paint_flashing_tool/index.html94
1 files changed, 94 insertions, 0 deletions
diff --git a/files/de/tools/paint_flashing_tool/index.html b/files/de/tools/paint_flashing_tool/index.html
new file mode 100644
index 0000000000..7fca9a3167
--- /dev/null
+++ b/files/de/tools/paint_flashing_tool/index.html
@@ -0,0 +1,94 @@
+---
+title: Paint Flashing Tool
+slug: Tools/Paint_Flashing_Tool
+translation_of: Tools/Paint_Flashing_Tool
+---
+<div>{{ToolsSidebar}}</div><p>The paint flashing tool, when activated, highlights the part of a page that the browser needs to repaint in response to some input: for example, the user moving the mouse or scrolling. With the help of this tool you can figure out whether your website is causing the browser to repaint more than it needs to. Because repaints can be performance-intensive operations, eliminating unnecessary repaints can improve your website's responsiveness.</p>
+
+<h2 id="Repaints_and_responsiveness">Repaints and responsiveness</h2>
+
+<p>When the browser renders a web page it parses the HTML and CSS, determines how to lay it out, and then paints it to actually display the content on the screen. Whenever an event happens that might change a visible part of the web page then the browser must repaint some portion of the page. For example, a repaint will be needed if the user scrolls the page or moves the mouse pointer over an element with a <a href="/en-US/docs/Web/CSS/:hover" title="/en-US/docs/Web/CSS/:hover"><code>:hover</code></a> pseudo-class that changes the element's style.</p>
+
+<p>Repainting can be an expensive operation, so the browser tries to minimise the amount of repainting that it needs to do. It tries to work out which parts of the screen are "damaged" and repaint only those. The browser also splits its model of the page into layers that it expects will be updated independently of each other. Layers are painted independently and then composited, so a change in the appearance of one layer does not trigger a repaint in any other layers, and when only the relation of two layers changes (in an animation, for example) no repaints are required at all.</p>
+
+<p>The choices made by a web developer can hinder the browser here, causing it to trigger more repaints, and for more of the screen, than necessary. This can then cause a site to be slow responding to user input (also known as "janky"). That's where the paint flashing tool helps: by showing you the areas that the browser repaints in response to an event, you can see whether it is repainting more than it needs to.</p>
+
+<h2 id="Using_the_paint_flashing_tool">Using the paint flashing tool</h2>
+
+<p>There are two ways to switch on paint flashing:</p>
+
+<ul>
+ <li>open the <a href="/en-US/docs/Tools_Toolbox" title="/en-US/docs/Tools_Toolbox">Toolbox</a>, then click the icon labeled "Highlight painted area":</li>
+</ul>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/5929/paint-flashing-open-from-toolbox.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+
+<ul>
+ <li>activate the <a href="/en-US/docs/Tools/GCLI" title="/en-US/docs/Tools/GCLI">Developer Toolbar</a> and type "paintflashing on", then press the Enter key:</li>
+</ul>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/5931/paint-flashing-open-from-toolbar.png" style="display: block; margin-left: auto; margin-right: auto;"></p>
+
+<p>Then try using the page. After moving the mouse around and scrolling a bit, the above page looks like this:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/5935/paint-flashing-activated.png" style="display: block; margin-left: auto; margin-right: auto;">In this example, there are two main sources of repaints:</p>
+
+<ul>
+ <li>moving the mouse over links makes the browser repaint them, because they have a style applied using the <a href="/en-US/docs/Web/CSS/:hover" title="/en-US/docs/Web/CSS/:hover"><code>:hover</code></a> pseudo-class</li>
+ <li>scrolling makes the browser repaint the new part of the page coming into view at the bottom of the screen, and also the scrollbar at the top-right</li>
+</ul>
+
+<p>To deactivate paint flashing, click the "Highlight painted area" icon in the Toolbox again, or type "paintflashing off" into the Developer Toolbar and press Enter.</p>
+
+<h2 id="Example_CSS_transitions">Example: CSS transitions</h2>
+
+<p>One area where implementation choices can affect repaint efficiency is in <a href="/en-US/docs/Web/Guide/CSS/Using_CSS_transitions" title="/en-US/docs/Web/Guide/CSS/Using_CSS_transitions">CSS transitions</a>. The example below shows two different ways to move an element using a CSS transition. The first way applies the transition to the element's <a href="/en-US/docs/Web/CSS/margin-left" title="/en-US/docs/Web/CSS/margin-left"><code>margin-left</code></a>, while the second way moves the element using the <a href="/en-US/docs/Web/CSS/transform" title="/en-US/docs/Web/CSS/transform"><code>transform</code></a> property.</p>
+
+<pre class="brush: html">&lt;body&gt;
+ &lt;div id="container"&gt;
+     &lt;div class="moving-box" id="moving-box-left-margin"&gt;Transition using margin-left&lt;/div&gt;
+     &lt;div class="moving-box" id="moving-box-transform"&gt;Transition using transform&lt;/div&gt;
+ &lt;/div&gt;
+&lt;/body&gt;
+
+</pre>
+
+<pre class="brush: css">#container {
+ border: 1px solid;
+}
+
+.moving-box {
+  height: 20%;
+  width:20%;
+  margin: 2%;
+  padding: 2%;
+  background-color: blue;
+  color: white;
+  font-size: 24px;
+}
+
+#moving-box-left-margin {
+  transition: margin-left 4s;
+}
+
+#moving-box-transform {
+  transition: transform 4s;
+}
+
+body:hover #moving-box-left-margin{
+  margin-left: 74%;
+}
+
+body:hover #moving-box-transform {
+  transform: translate(300%);
+}</pre>
+
+<p>To see the transition, move the mouse into the space below:</p>
+
+<p>{{ EmbedLiveSample('Example.3A_CSS_transitions', 600, 300) }}</p>
+
+<p>Now switch paint flashing on, and try it again. You should see that the <code>margin-left</code> version triggers a series of repaints as the element moves, while the <code>transform</code> version only causes repaints in the start and end positions.</p>
+
+<p>Why? Well, when you use <code>transform</code>, the browser creates a separate layer for the element. So when the element is moved, all that's changed is the relation of the two layers to each other, which is handled in composition: neither layer needs a repaint.</p>
+
+<p>In this case, with a simple style, the extra repaints don't make much of a difference. But if the style were computationally expensive to paint, they might. It's difficult to know what optimizations the browser will make to minimize repaints, and they are subject to change from one version to the next. So testing your website with the paint flashing tool helps ensure that it's still performing optimally.</p>