# How to add External javascript library in Ionic2 Application

**URL:** <https://forum.ionicframework.com/t/how-to-add-external-javascript-library-in-ionic2-application/87669>\
**Category:** ionic-v3\
**Created:** [April 24, 2017, 5:26pm UTC](https://forum.ionicframework.com/t/how-to-add-external-javascript-library-in-ionic2-application/87669 "2017-04-24T17:26:41Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![lucasbasquerotto](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/lucasbasquerotto/32/101719_2.png) [@lucasbasquerotto](https://forum.ionicframework.com/u/lucasbasquerotto)\
**Post date:** [April 24, 2017, 6:33pm UTC](https://forum.ionicframework.com/t/how-to-add-external-javascript-library-in-ionic2-application/87669/3 "2017-04-24T18:33:58Z")

</div>

@rhuldip For these kind of files, in my case I’ve put them inside `/src/assets/js/`, because they will be copied to the `/www/assets/js/` folder, then I reference it in `index.html` and declare it (you can declare in `declarations.d.ts`).

For example, lets say you have a file named `my-library.min.js` that is accessed through the `MyLibrary` global variable (that is, `window.MyLibrary`). Then:

**1)** Put `my-library.min.js` inside `/src/assets/js/` (if the folder `/src/assets/` doesn’t have a sub-folder `/js`, just create it).

**2)** In `/src/index.html` include the `script` tag:

`<script src="assets/js/my-library.min.js"></script>`

**3)** In `/src/declarations.d.ts` include:

`declare var MyLibrary: any;`

**4)** Use it:

```auto
export class MyApp implements OnInit {

	public ngOnInit() {
		console.log('MyLibrary', MyLibrary);
		MyLibrary.doSomething();
	}
	
}

```

---

_[View the full topic](https://forum.ionicframework.com/t/how-to-add-external-javascript-library-in-ionic2-application/87669)._
