Skip to content

Performance Considerations

When developing applications using the enClose framework, ensuring optimal performance is crucial for a smooth user experience. Below are key considerations to maintain high performance.

Communication Overhead

  • Minimize JS-Native Calls: Excessive calls between JavaScript and Swift can cause bottlenecks; batch operations where possible.

Rendering & UI Performance

  • Reduce DOM Complexity: A large number of elements or deep nesting slows rendering.
  • Optimize CSS and Animations: Prefer transform and opacity over top/left for smooth transitions.
  • Use requestAnimationFrame(): Helps ensure smoother animations in JavaScript.
  • Lazy Load Content: Render only what is visible to avoid unnecessary processing.

Memory Management

  • Monitor Memory Usage: Prevent memory leaks in both Swift and JavaScript.

Networking

  • Optimize API Calls: Use request batching, compression, and WebSockets over frequent polling.
  • Use Background Threads for Requests: Avoid blocking the main UI thread with networking operations.

Native Code Execution

  • Offload Heavy Tasks to Native: Processing-intensive tasks (e.g., image manipulation) should run in Swift rather than JavaScript.
  • Use Background Threads for Expensive Operations: Prevent UI slowdowns by executing heavy tasks off the main thread.

App Startup Time

  • Defer JS Execution: Load only critical JavaScript at startup; lazy-load the rest.
  • Use a Native Splash Screen: Provides a better user experience while the WebView initializes.

By following these best practices, your hybrid app will maintain high performance, delivering a responsive and seamless experience for users.