Is prefetching assets considered harmful when using assetBundlePatterns?

Part of my question was previously answered here: Trying to understand assetBundlePatterns.
Namely, "do I need to prefetch assets with Asset/ Font.downloadAsync() anymore once I’ve put them into assetBundlePatterns (the answer is no).

My next question is, if you happened to both include an asset/ font in the assetBundlePatterns and prefetched it, would there be a redundant network request (which could go slow or cause some failure in a low/ no network situation)? Or would it see the asset was already cached and move on?

The reason I’m considering doing this is…
a) assets aren’t bundled when you run in the Expo app (right?). So you’ll see funny stuff like images coming in late if you don’t prefetch (minor reason), and…
b) (much more important) even if a font is bundled with assetBundlePatterns, it seems like you still need to call Font.downloadAsync() in order to register the font for usage (right?)


bumping since I’m about to deploy my first Expo 25-based updated and I’m quite curious about this. :slight_smile: Thanks!

I’ll confer with the team about best practices regarding asset loading and get back to you today, @llamaluvr.

1 Like

Alright, so regardless of if you’re prefetching or bundling an asset, you will need to call Font.downloadAsync() to register the font for use, but if the font asset is bundled it will pull from bundle rather than perform a network request. In your standalone project, prefetching an asset that is part of your bundle will create a copy of your asset so you don’t want to do that, but as you mentioned, you will need to prefetch when running your project within the Expo Client to avoid delayed image loading and what not.




As I understand so far:

  1. Prefetching an asset that is part of your standalone app’s bundle will create a copy of the asset.
  2. Fonts have to be prefetched, but if they’re bundled with a standalone app, they’ll be pulled from the bundle instead of there being a network request for the font.

So, remaining questions based on that:

  1. Does the Font prefetching create a second copy of the Font when it’s bundled? (not a big deal but you know curious)
  2. Is the second copy of an asset that is created when you prefetch something that is already bundled with your standalone app downloaded over the network or pulled from the bundle (like the font)?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.