← Back to Tips & Tricks
Power Apps
Gallery Performance Optimization
Speed up slow galleries with lazy loading, optimized templates, and smart data strategies.
Why Galleries Slow Down
Galleries can become sluggish due to:
- Too many controls per item
- Complex formulas in templates
- Large images or media
- Non-delegable data sources
Optimization Techniques
1. Limit Visible Items
// Instead of loading all records
Gallery.Items = DataSource
// Load a limited set
Gallery.Items = FirstN(DataSource, 50)
2. Simplify Gallery Templates
- Reduce controls to under 5 per item
- Avoid nested galleries
- Remove unnecessary borders and effects
3. Use DelayOutput on Search
SearchBox.DelayOutput = true
SearchBox.OnChange = // Don't need this anymore
This prevents the gallery from refreshing on every keystroke.
4. Cache Data with Collections
// Load once on app start
ClearCollect(colProducts, Products);
// Use collection in gallery
Gallery.Items = Filter(colProducts, StartsWith(Name, SearchBox.Text))
5. Optimize Images
- Use thumbnails instead of full images
- Set image control to Fit mode, not Fill
- Consider using image URLs instead of embedding
Loading Pattern
// Show loading indicator
Set(varLoading, true);
ClearCollect(colData, DataSource);
Set(varLoading, false);
// In your gallery
If(varLoading,
ShowLoadingSpinner,
Gallery
)
Measuring Performance
Use the Power Apps Monitor to identify slow operations:
- Open your app in the editor
- Go to Advanced tools > Monitor
- Run the app and interact with galleries
- Look for operations taking > 500ms
Rule of thumb: If your gallery has more than 3 controls or shows more than 100 items, consider optimization.