You can do this by
Edit page -> Add web part -> Media and content -> Content editor -> Add
Edit the source of the web part and add the following code into it:
Add the js file under Site Assets using SharePoint Designer.
The best approach would be to use a Content Editor Web Part or a Script Editor Web Part. You can achieve this by going to your page, Edit Page, Add Web Part and select the Content Editor Web Part. Inside the Content Editor web part click on View Source in the ribbon and paste in your JS script in there.
Another great approach is to put your plugin into a .txt file and save it in your Site Assets library. Add the Content Web Part and open the Properties for it. Inside of the properties you can paste the path to .txt file with your plugin.
If you can post the script on here for reference, I can show you a visual example.