Adding action to textarea
The technique you need is easy, the full details can be complicated (depending on exactly what you want the JS to do). You can attach a custom JavaScript file from without your module in three steps:


Create the JS file.
Define a library.
Attach the library to the form element.


The JavaScript should typically live in a folder named js at the root of your module: js/my-great-jscode.js.

To create your library add a [module_name].libraries.yml file to the root of your custom module.  In there define the library:

my-library:
  version: 1.x
  js:
    js/my-great-jscode.js: {}


Then to attach the code to your form element you add #attached =&gt; library to the render array. 

$the_textarea=array(
  '#type' =&gt; 'textarea',
  '#required' =&gt; FALSE,
  '#ajax' =&gt; array (
  // Function to call when event on form element triggered.
  'callback' =&gt; array($this-&gt;componentCallbackObject,$this-&gt;componentCallbackFunction),
  'event' =&gt; $this-&gt;componentEvent,
  ),
  '#attached' =&gt; [
    'library' =&gt; [
      'my-module/my-library',
    ],
  ],
);


There is more detail in Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 module on Drupal.org