Attach js file to every page w/term reference widget in Drupal 8
'#attached' works for any element. You should have an element in scope in that alter hook. Also you should have a mymodule.libraries.yml to declare your script.