You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,32 @@
3
3
4
4
Load external javascript libraries/files (e.g. Google Maps JavaScript API, Stripe JavaScript API, ...) in your components and services on the fly (when you need them) and execute code as soon as it's loaded.
5
5
6
+
## Introduction
7
+
There are mainly two options to include a javascript library into your Angular project:
8
+
- Add it via the package manager ``npm``
9
+
- Include it in your ``index.html`` file
10
+
11
+
However, sometimes
12
+
- You don't want to include it upfront in your application to reduce size
13
+
and thus initial loading time of your application.
14
+
- An appropriate ``npm`` package does not exist and you
15
+
don't want to add the library to ``index.html``.
16
+
17
+
18
+
🌟 This library provides a service to lazy load javascript libraries when you need them,
19
+
one a component and service basis.
20
+
21
+
#### Features
22
+
- Provides an Angular service to load javascript files.
23
+
- The service loads each library only once, i.e. remembers which libraries were already loaded.
24
+
- You can subscribe to the returned observable to execute code relying on the lazy loaded script.
25
+
6
26
## Installation
7
27
Using npm:
8
28
```
9
29
npm i --save @ueler/ng-lazyload-script
10
30
```
11
31
12
-
## Features
13
-
- Provides an Angular service to load javascript files.
14
-
- The service loads each library only once, i.e. remembers which libraries were already loaded.
15
-
- You can subscribe to the returned observable to execute code relying on the lazy loaded script.
16
-
17
32
## How does it work?
18
33
The service creates a ``<script>`` tag with the provided source url and appends it to the document body.
0 commit comments