Avoid downloading Snapping related files?

09-26-2023 07:07 PM
New Contributor II



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.








0 Kudos
3 Replies
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.

New Contributor II

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
Occasional Contributor III

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