Angular Dynamic templates with different CSS, JS and JS files and jQuery versions

I am building an Angular application whereby users have the ability to select HTML(CSS, jQuery, JS) templates for their site. All templates are totally different from one another. For example, template one can have Bootstrap version 3 and jQuery verison 3. Template 2 can have Bootstrap version 5 and jQuery 2.

So far, I have this working by using lazy loaded routes and dynamically adding scripts to the files.
The issue with this is sometimes, the scripts do not load.
Is there something I’m doing wrong or is there a better way to handle such a problem?