<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RUM JavaScript injection; synchronous vs asynchronous (deferred) in Real User Monitoring</title>
    <link>https://community.dynatrace.com/t5/Real-User-Monitoring/RUM-JavaScript-injection-synchronous-vs-asynchronous-deferred/m-p/196301#M3916</link>
    <description>&lt;P&gt;Hi there is some discussion with a customer in relation whether or not to load the Dynatrace injection, and when and how. The Dynatrace OneAgents are deployed, full stack.&lt;BR /&gt;The OneAgent does the automatic injection (as designed). This results in the inserted code to appear at the top of the pages, synchronously loaded, marked as render blocking, which means the page cannot render anything until the script has been read, parsed and executed. Causing delay in showing content on the screen to the end user.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The suggestion is raised to perhaps load the script later, and at least investigate to set the injection method to&amp;nbsp;asynchronous (deferred), instead of&amp;nbsp;synchronous.&lt;BR /&gt;As stated &lt;A title="RUM JavaScript injection" href="https://www.dynatrace.com/support/help/shortlink/rum-injection" target="_blank" rel="noopener"&gt;in the RUM JavaScript injection documentation&lt;/A&gt;, the Dynatrace OneAgent can leverage all injection formats listed under manual insertion to automatically integrate RUM into your application, which includes 'Code snippet synchronous (syncCS)' and 'Code snippet deferred (asyncCS)'.&lt;BR /&gt;&lt;BR /&gt;However I cannot determine all the pro's and con's of either format (besides what is stated under When to use), or switching from the standard in terms of speed and completeness of monitoring; So the questions I have:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;- what is the impact and consequence of using deferred (async)?&lt;/P&gt;&lt;P&gt;- what are other pro's and con's not listed to use either format?&lt;/P&gt;&lt;P&gt;- and switching from default injected OneAgent Javascript tag&lt;BR /&gt;- (manually) loading the script later (than other) items.&lt;/P&gt;&lt;P&gt;- has caching an impact? What is the best approach there?&lt;BR /&gt;&lt;BR /&gt;It might be good if there are significant factors, to add those to the documentation.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fstekelenburg_0-1665570903592.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/7979i46FF365FA942ABA0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="fstekelenburg_0-1665570903592.png" alt="fstekelenburg_0-1665570903592.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note:&amp;nbsp;Deferring loading and/or rendering of JavaScript functions that are not called at startup reduces the initial download size, allowing other resources to be downloaded in parallel, and speeding up execution and rendering time.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_17a21104.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/7980iFF2A3B263B0B0385/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snag_17a21104.png" alt="Snag_17a21104.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_17a236eb.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/7981iABA7AD35584B8BA9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snag_17a236eb.png" alt="Snag_17a236eb.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
    <pubDate>Wed, 12 Oct 2022 10:53:27 GMT</pubDate>
    <dc:creator>fstekelenburg</dc:creator>
    <dc:date>2022-10-12T10:53:27Z</dc:date>
    <item>
      <title>RUM JavaScript injection; synchronous vs asynchronous (deferred)</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/RUM-JavaScript-injection-synchronous-vs-asynchronous-deferred/m-p/196301#M3916</link>
      <description>&lt;P&gt;Hi there is some discussion with a customer in relation whether or not to load the Dynatrace injection, and when and how. The Dynatrace OneAgents are deployed, full stack.&lt;BR /&gt;The OneAgent does the automatic injection (as designed). This results in the inserted code to appear at the top of the pages, synchronously loaded, marked as render blocking, which means the page cannot render anything until the script has been read, parsed and executed. Causing delay in showing content on the screen to the end user.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The suggestion is raised to perhaps load the script later, and at least investigate to set the injection method to&amp;nbsp;asynchronous (deferred), instead of&amp;nbsp;synchronous.&lt;BR /&gt;As stated &lt;A title="RUM JavaScript injection" href="https://www.dynatrace.com/support/help/shortlink/rum-injection" target="_blank" rel="noopener"&gt;in the RUM JavaScript injection documentation&lt;/A&gt;, the Dynatrace OneAgent can leverage all injection formats listed under manual insertion to automatically integrate RUM into your application, which includes 'Code snippet synchronous (syncCS)' and 'Code snippet deferred (asyncCS)'.&lt;BR /&gt;&lt;BR /&gt;However I cannot determine all the pro's and con's of either format (besides what is stated under When to use), or switching from the standard in terms of speed and completeness of monitoring; So the questions I have:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;- what is the impact and consequence of using deferred (async)?&lt;/P&gt;&lt;P&gt;- what are other pro's and con's not listed to use either format?&lt;/P&gt;&lt;P&gt;- and switching from default injected OneAgent Javascript tag&lt;BR /&gt;- (manually) loading the script later (than other) items.&lt;/P&gt;&lt;P&gt;- has caching an impact? What is the best approach there?&lt;BR /&gt;&lt;BR /&gt;It might be good if there are significant factors, to add those to the documentation.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fstekelenburg_0-1665570903592.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/7979i46FF365FA942ABA0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="fstekelenburg_0-1665570903592.png" alt="fstekelenburg_0-1665570903592.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note:&amp;nbsp;Deferring loading and/or rendering of JavaScript functions that are not called at startup reduces the initial download size, allowing other resources to be downloaded in parallel, and speeding up execution and rendering time.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_17a21104.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/7980iFF2A3B263B0B0385/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snag_17a21104.png" alt="Snag_17a21104.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_17a236eb.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/7981iABA7AD35584B8BA9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snag_17a236eb.png" alt="Snag_17a236eb.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 10:53:27 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/RUM-JavaScript-injection-synchronous-vs-asynchronous-deferred/m-p/196301#M3916</guid>
      <dc:creator>fstekelenburg</dc:creator>
      <dc:date>2022-10-12T10:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: RUM JavaScript injection; synchronous vs asynchronous (deferred)</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/RUM-JavaScript-injection-synchronous-vs-asynchronous-deferred/m-p/196532#M3927</link>
      <description>&lt;P&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/25371"&gt;@Radoslaw_Szulgo&lt;/a&gt;&amp;nbsp;do you know which of the experts from the Dyna-team can answer this best?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 13:11:00 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/RUM-JavaScript-injection-synchronous-vs-asynchronous-deferred/m-p/196532#M3927</guid>
      <dc:creator>fstekelenburg</dc:creator>
      <dc:date>2022-10-14T13:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: RUM JavaScript injection; synchronous vs asynchronous (deferred)</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/RUM-JavaScript-injection-synchronous-vs-asynchronous-deferred/m-p/200620#M4013</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/21639"&gt;@fstekelenburg&lt;/a&gt;&amp;nbsp;, thank you for your patience. Not sure if you've already received the answer from other channels,&amp;nbsp;but I'll leave my thoughts for the reference and the community.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What are the impact and consequences of using deferred (async)?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In short, the impact is the page's loading time is shorter as the full functionality is loaded asynchronously. Users&lt;SPAN&gt;&amp;nbsp;can read page content and get acquainted with the page immediately.&amp;nbsp;&lt;/SPAN&gt;You need to&lt;SPAN&gt;&amp;nbsp;manually insert it into your web application code, which&amp;nbsp;requires regular code snippet updates to guarantee compatibility (tested for one year).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Technically:&lt;/P&gt;
&lt;P&gt;The&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;defer&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;attribute tells the browser not to wait for the script. Instead, the browser will continue to process the HTML and build DOM. The script loads “in the background” and runs when the DOM is fully assembled.&amp;nbsp;In other words:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;OneAgent JavaScript with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;defer&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;never block the page.&lt;/LI&gt;
&lt;LI&gt;OneAgent JavaScript with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;defer&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;consistently execute when the DOM is ready (but before the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;DOMContentLoaded&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;event).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;What are the other pros and cons of using async (deferred) compared to other formats?&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Pros:&lt;/P&gt;
&lt;P&gt;- Non-blocking load, so page loads quickly and the risk of a page error is minimized&lt;/P&gt;
&lt;P&gt;- C&lt;SPAN&gt;onfiguration updates are immediately reflected on the client of your real users&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- Monitoring updates are automatic&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cons:&lt;/P&gt;
&lt;P&gt;- Manual insertion&lt;/P&gt;
&lt;P&gt;- monitoring and code are not up[dated according to the caching duration set in Dynatrace.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Does caching have an impact? What is the best approach there?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Caching always has an impact. The best option is to defer all scripts and inject the OneAgent as the first deferred script (the order will stay correct). As written in the docs:&lt;/P&gt;
&lt;BLOCKQUOTE class="c-mrkdwn__quote" data-stringify-type="quote"&gt;OneAgent always tries to inject its RUM JavaScript as the first script on the page. This helps to keep your web application intact but also guarantees more reliable monitoring results (for example, timing). If you insert the RUM JavaScript manually, ensure that it's the first executable script on each page.
&lt;P class="1671118663928"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="table__container"&gt;
&lt;TABLE class="table"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class=""&gt;
&lt;P&gt;If you use async (deferred) mode, you must configure the caching in your own environment using your web server configuration.&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;DIV class="callout callout--default"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 15 Dec 2022 16:01:59 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/RUM-JavaScript-injection-synchronous-vs-asynchronous-deferred/m-p/200620#M4013</guid>
      <dc:creator>Radoslaw_Szulgo</dc:creator>
      <dc:date>2022-12-15T16:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: RUM JavaScript injection; synchronous vs asynchronous (deferred)</title>
      <link>https://community.dynatrace.com/t5/Real-User-Monitoring/RUM-JavaScript-injection-synchronous-vs-asynchronous-deferred/m-p/200653#M4015</link>
      <description>&lt;P&gt;Another benefit of having the deferred version - the loading of the page won't be blocked if the source of Dynatrace JS cannot be reached by the client.&lt;BR /&gt;Loading it synchronously in such cases will cause either loading the page to fail or huge loading times until the request times out.&lt;BR /&gt;&lt;BR /&gt;It has also a con - You won't have all information about what happened during page load before the RUM JS was actually loaded.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 08:14:49 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Real-User-Monitoring/RUM-JavaScript-injection-synchronous-vs-asynchronous-deferred/m-p/200653#M4015</guid>
      <dc:creator>Julius_Loman</dc:creator>
      <dc:date>2022-12-16T08:14:49Z</dc:date>
    </item>
  </channel>
</rss>

