<?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 Re: Fully pre-load geometryEngineAsync? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/fully-pre-load-geometryengineasync/m-p/1026123#M71750</link>
    <description>&lt;P&gt;You can try a link with a &lt;A href="https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content" target="_self"&gt;preload&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;link rel="preload" href="https://js.arcgis.com/4.18/esri/geometry/geometryEngineAsync.js" as="script"&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or, you can always call loadModules for it as soon as the app starts, it will be cached for later use.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Feb 2021 00:08:57 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2021-02-12T00:08:57Z</dc:date>
    <item>
      <title>Fully pre-load geometryEngineAsync?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/fully-pre-load-geometryengineasync/m-p/1026111#M71749</link>
      <description>&lt;P&gt;I've been really enjoying `geometryEngineAsync` in my JS apps. I'm loading v 4.18 into an Angular 11 app with `esri-loader`.&lt;/P&gt;&lt;P&gt;The first time I invoke the `union` method on an array of Polygons, there are numerous scripts downloaded. My questions is this: Is there a way to preload these scripts prior to calling the fuction?&lt;/P&gt;&lt;P&gt;The first time I render the Sketch Widget graphics, there's a bit of lag. After that it's buttery smooth.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AndrewVitale_1-1613084720534.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5880i511CD2CCFC69C7C2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AndrewVitale_1-1613084720534.png" alt="AndrewVitale_1-1613084720534.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 23:06:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/fully-pre-load-geometryengineasync/m-p/1026111#M71749</guid>
      <dc:creator>AndrewVitale</dc:creator>
      <dc:date>2021-02-11T23:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Fully pre-load geometryEngineAsync?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/fully-pre-load-geometryengineasync/m-p/1026123#M71750</link>
      <description>&lt;P&gt;You can try a link with a &lt;A href="https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content" target="_self"&gt;preload&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;link rel="preload" href="https://js.arcgis.com/4.18/esri/geometry/geometryEngineAsync.js" as="script"&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or, you can always call loadModules for it as soon as the app starts, it will be cached for later use.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 00:08:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/fully-pre-load-geometryengineasync/m-p/1026123#M71750</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-02-12T00:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Fully pre-load geometryEngineAsync?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/fully-pre-load-geometryengineasync/m-p/1026243#M71753</link>
      <description>&lt;P&gt;Hi Rene,&lt;/P&gt;&lt;P&gt;Thanks for the quick reply! I did not know about the rel="preload" property. I'll def keep that in mind.&lt;/P&gt;&lt;P&gt;I do believe that I am calling loadModules on the initialization of my component, which is when the geometryEngine*.js scripts are added. However it appears that the worker threads don't get hydrated with the geometryEngineWorker.js scripts until the union method is invoked. Check out the waterfall here:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AndrewVitale_0-1613135420614.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5900iAEEAA98E3C1DFDA5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AndrewVitale_0-1613135420614.png" alt="AndrewVitale_0-1613135420614.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With fresh eyes, it seems like calling the method on an empty array after the geometryEngineAsync has loaded is giving me the desired result... The threads are loaded and ready to rip by the time the user would get around to interacting with the map.&lt;/P&gt;&lt;P&gt;Is there any reason &lt;I&gt;not&amp;nbsp;&lt;/I&gt;to do this?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Angular 11 service

@Injectable({
  providedIn: 'root'
})
export class UnionModulesService {
  public geometryEngineAsync: __esri.geometryEngineAsync;
  public Graphic: __esri.GraphicConstructor;

  constructor() {}

  public async loadModules(
    esriStore: EsriStore
  ) : Promise&amp;lt;[__esri.geometryEngineAsync, __esri.GraphicConstructor]&amp;gt; {
    try {
      if (this.geometryEngineAsync &amp;amp;&amp;amp; this.Graphic) {
        return [this.geometryEngineAsync, this.Graphic];
      } else {
        const [geometryEngineAsync, Graphic] = await esriStore.require&amp;lt;
          [__esri.geometryEngineAsync, __esri.GraphicConstructor]
        &amp;gt;(['esri/geometry/geometryEngineAsync', 'esri/Graphic']);

        this.geometryEngineAsync = geometryEngineAsync;
        this.Graphic = Graphic;

        // Call the union method on an empty array to get everything ready?
        this.geometryEngineAsync
          .union([])
          .then((x) =&amp;gt; console.log('warmed it up', x));

        return [geometryEngineAsync, Graphic];
      }
    } catch (error) {
      console.error('UnionModulesService.loadModules', error);
      throw error;
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2021 13:21:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/fully-pre-load-geometryengineasync/m-p/1026243#M71753</guid>
      <dc:creator>AndrewVitale</dc:creator>
      <dc:date>2021-02-12T13:21:38Z</dc:date>
    </item>
  </channel>
</rss>

