If you want to add some JS code, like some kind of snippet to your pages with libraries.yml, add it as any other library item but don't use jquery or drupal behaviours in .js code, add some plain JS code like
document.addEventListener("DOMContentLoaded", function() {
so to wrap some JS snippet for it, do it like below.