In my Angular home.component.ts file, I have added the script loading code as shown below:
export class HomeComponent {
constructor() {
this.loadDynamicScript();
}
public loadDynamicScript() {
var script = document.createElement('script');
script.src = "../node_modules/xxxxxx/i18n/xx.min.js";
script.async = false;
document.head.appendChild(script);
}
The issue I am facing is that the file is being loaded after the components are created, rendering it useless. How can I ensure that the file is loaded immediately after being appended to the document?