Why is my javascript not being executed? I have a Drupal 8 form and I'm applying some custom javascript to it. I've added a JS file, and a libraries file for my module containing a reference to it, but the code doesn't run.

in module_name/js/autocomplete.js

(function ($, Drupal, drupalSettings) {

  Drupal.behaviors.modulename_autocomplete = {
    attach: function (context, settings) {

      jQuery(function() {
        // Doesn't work
        console.log('foo');

        // Doesn't work
        alert('bar');

      });
    }
  };
})(jQuery, Drupal, drupalSettings);


and in module_name.libraries.yml

module_name.autocomplete:
  version: 1.0
  js:
    js/autocomplete.js: {}
  dependencies:
    - core/jquery
    - core/jquery.ui.autocomplete


As the comments suggest, I see no console messages and no alert, so it's clear the behavior is not being executed.

What do I need to change for this to work?
You don't attach your to your form:

$form['#attached']['library'][] = 'module_name/library_name';


Just a suggestion: 

In your library yml it's unnecessary to append your module name to your library name.