Moving js (or/and css) to another bundle

When testing DataTables, I noticed that the javascript only loads for logged in users.

What is 'the right way' to move something from one bundle to another, in an add on (profile)?

(or should it have its own bundle ? )

see here

I did a quick test, but ended up with javascript errors

I dont know if it is a good idea, but using 'require' in the template seems to work:

<script>
require([
  'jquery',
  '++plone++static/plone-datatables-compiled.min.js'
  ], function(Base) {
    'use strict';
    $('.sortable').DataTable( {
        rest of script here
      });
  });
</script>

PS: I have no idea why pat-moment also gives an error. This is a fresh (5.2) site

UPDATE: I only read the last answer, seems like others have used a similar approach.

Plone Foundation Code of Conduct