1. Create a file module_name.libraries.yml and add the below codePlugin_name:
version: 1.x
js:
js/JS_FILE_NAME: {}
2. Implement the below hook into your module_name.module filefunction module_name_page_attachments_alter(array &$attachments) {
$attachments['#attached']['library'][] = 'module_name/plugin_name';
}3. Place your js file into module folder inside the js folder.