Select to view content in your preferred language

Avoid downloading Snapping related files?

504
3
09-26-2023 07:07 PM
JonathanTiu
Emerging Contributor

Hi!

 

we're using the esri-loader loadModules to download only what we need to use from the JS arcgis sdk.

I notice in the network tab that SnappingEngine and FeatureSnappingManager are being downloaded always.... followed by at least a dozen related files on snapping (see screenshots below)

We are trying to really minimize what we dow

nload to only what we use use and we don't use any snapping functionality. Is there a way to prevent the download of all these files?

We do use SketchViewModel but not the Sketch widget.

this is what we currently download.  I'm not sure what is trying to pull in the snapping stuff...or how to stop it.

 'esri/config',
    'esri/Basemap',
    'esri/Color',
    'esri/geometry/Extent',
    'esri/geometry/geometryEngine',
    'esri/geometry/support/normalizeUtils',
    'esri/geometry/support/spatialReferenceUtils',
    'esri/Map',
    'esri/views/MapView',
    'esri/widgets/ScaleBar',
    'esri/geometry/SpatialReference',
    'esri/layers/GraphicsLayer',
    'esri/layers/TileLayer',
    'esri/layers/VectorTileLayer',
    'esri/Graphic',
    'esri/geometry/Point',
    'esri/geometry/Polygon',
    'esri/geometry/Polyline',
    'esri/symbols/Font',
    'esri/symbols/SimpleFillSymbol',
    'esri/symbols/SimpleLineSymbol',
    'esri/symbols/SimpleMarkerSymbol',
    'esri/symbols/TextSymbol',
    'esri/geometry/support/webMercatorUtils',
    'esri/core/reactiveUtils',
    'esri/widgets/Sketch/SketchViewModel'
 

 

JonathanTiu_3-1695780423506.png

 

JonathanTiu_2-1695780404842.png

 

 

0 Kudos
3 Replies
AndyGup
Esri Regular Contributor

Hi @JonathanTiu sometimes, some of the internal dependency relationships cause seemingly unrelated modules to be loaded. We do our best to stay on top of addressing unneeded dependencies that could be lazy loaded or treeshaken. The AMD CDN is highly optimized, as far as CDN performance goes.

Depending on your use cases, If you have more exacting needs than can be addressed using the CDN, you might also look at using the ES modules via @arcgis/core. Then you have somewhat different control mechanisms (but not necessarily more optimized), by using a local module bundler to create the final on-disk module output.

JonathanTiu
Emerging Contributor

Thanks Andy!  No worries. i was just trying to snoop around to see if there was anything more i could try to eliminate in terms of unnecessary downloads. we're in that part of our performance testing where we're trying to be ruthless 🙂  

the good news is i've managed to pick off all the low hanging fruit and made some big gains. from what i estimate, the snapping files seem to total in the neighbourhood of ~50k so not huge. but every bit counts 🙂

0 Kudos
JoelBennett
MVP Regular Contributor

There doesn't presently appear to be any way to avoid this.  The SketchViewModel module has a dependency on SnappingManager, as well as a couple other snapping modules, and the rest of it likely cascades from there.  Chances are, if you temporarily commented out your requirement for SketchViewModel and loaded your application, you wouldn't see all those snapping modules being brought in.

0 Kudos