DEV Community


Posted on • Originally published at

How to Load External Scripts Dynamically In Angular 14+

In this tutorial, we will see how to load external scripts Dynamically In Angular 14.

The technique listed below can be used to dynamically load JS scripts and libraries into your Angular project as needed.

loadScript(): Promise<any> {

return new Promise((resolve, reject) => {

const script = document.createElement('script');

script.src =


script.async = true;

script.defer = true;



Top comments (0)

Regex for lazy developers

regex for lazy devs

You know who you are. Sorry for the callout πŸ˜†