Menu

Post image 1
Post image 2
Post image 3
Post image 4
Post image 5
Post image 6
Post image 7
Post image 8
1 / 8
0

Angular’s New injectAsync() API Explained

DEV Community·Brian Treese·25 days ago
#iWu2yAig
Reading 0:00
15s threshold

A ngular v22 just made lazy-loading services much simpler. In this post, we'll explore how to leverage the new injectAsync() API to reduce your main bundle size and replace awkward lazy-loading workarounds. We’ll compare the older manual lazy-loading approach with Angular v22’s new injectAsync() API and see why the new pattern feels simpler and easier to reason about. The Problem: Libraries Loading Too Early When building Angular applications, it's common to include third-party libraries for various functionalities. However, if these libraries are not loaded efficiently, they can increase your initial bundle size, leading to slower application startup times. In our demo application , we're using highlight.js and Marked for markdown processing and syntax highlighting. In this case, the post-editor component itself is needed immediately, but the markdown-processing dependency isn’t.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More