Follow the link below to Check Out the Ultimate Guide on How to add Javascript & jQuery to WordPress
Install and use the Insert Headers and Footers plugin to add custom JavaScript code or third-party libraries on your WordPress site.
Easily add JS snippets, such as Google Analytics, Facebook tracking code or even your own custom JS code.
You can insert inline JS code or load external JS files or libraries using the src attribute on the script tags
Insert Headers and Footers plugin: