Select specific javascript parts of the bootstrap.min.js of Bootstrap to reduce its size

I am building a site with Bootstrap, but I would like to reduce the size of the Javascript botstrap.min.js file. I would like to use only those few JS parts that I use and are currently only offcanvas.js and dropdown.js. I tried several ways sought on the web, but I did not succeed. As the last way I simply tried this (but it doesn’t work even):

<script src="js/offcanvas.js"></script>
<script src="js/dropdown.js"></script>

The solutions found on the web are these two of the Bootstrap website: Lean JavaScript or Webpack e bundler, but I don’t know how to apply them because I didn’t understand much about the explanation.

I have already reduced the size of the CSS file with Sass and Scss and with Purgecss, but I have no idea how I can do the same for bootstrap.min.js. As for the reduced CSS, I would like to have only one file to import (for example my-bootstrap.js) in which Impbiesto aganvas.js and dropdown.js in it

Someone can show me a practical example of how I can reduce the bootstrap.min.js file and select only the specific parts I use?