DEV Community

Cover image for Make your Angular App faster using Dynamic import
mridul037
mridul037

Posted on

2 1

Make your Angular App faster using Dynamic import

Tips to make your angular app faster:

while importing your module using lazy loading helps

{ π‘π‘Žπ‘‘β„Ž: 'β„Žπ‘œπ‘šπ‘’', π‘π‘œπ‘šπ‘π‘œπ‘›π‘’π‘›π‘‘: π»π‘œπ‘šπ‘’πΆπ‘œπ‘šπ‘π‘œπ‘›π‘’π‘›π‘‘;}

To using loadChildren:

{π‘π‘Žπ‘‘β„Ž: 'β„Žπ‘œπ‘šπ‘’', π‘™π‘œπ‘Žπ‘‘πΆβ„Žπ‘–π‘™π‘‘π‘Ÿπ‘’π‘›: './β„Žπ‘œπ‘šπ‘’/β„Žπ‘œπ‘šπ‘’.π‘šπ‘œπ‘‘π‘’π‘™π‘’#π»π‘œπ‘šπ‘’π‘€π‘œπ‘‘π‘’π‘™π‘’'}

to make even better use dynamic import() function in Javascript.

{
π‘π‘Žπ‘‘β„Ž: 'β„Žπ‘œπ‘šπ‘’',
π‘™π‘œπ‘Žπ‘‘πΆβ„Žπ‘–π‘™π‘‘π‘Ÿπ‘’π‘›: () => π‘–π‘šπ‘π‘œπ‘Ÿπ‘‘('./β„Žπ‘œπ‘šπ‘’/β„Žπ‘œπ‘šπ‘’.π‘šπ‘œπ‘‘π‘’π‘™π‘’').π‘‘β„Žπ‘’π‘›(π‘š =>
π‘š.π»π‘œπ‘šπ‘’π‘€π‘œπ‘‘π‘’π‘™π‘’)
},

import statement return a promise. you read more about in given link.

link:: https://javascript.info/modules-dynamic-imports

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series πŸ“Ί

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series πŸ‘€

Watch the Youtube series

πŸ‘‹ Kindness is contagious

Please consider leaving a ❀️ or a friendly comment if you found this post helpful!

Okay