Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
how to load two JS files returning same global variable in Angular 10

Hello guys I have 2 JS files which returns window Object. but when I load these two files in angular the first js file is getting overridden by second js file due to global object.

Below are the Scripts

script1

public createFirstScript() {
let scriptsArray = ["firstUrl"]
for (let scriptIn of scriptsArray) {
const script = document.createElement('script');
script.setAttribute('id', scriptIn);
script.crossOrigin = 'anonymous';
let lang =  'en';
script.src = environment.service[scriptIn][lang];
document.head.appendChild(script);
}
}

script returns window object which needs to be loaded to get dynamic data which

returns (window).data


script2

public createSecondScript() {
let scriptsArray = ["secondUrl"]
for (let scriptIn of scriptsArray) {
const script = document.createElement('script');
script.setAttribute('id', scriptIn);
script.crossOrigin = 'anonymous';
let lang =  'en';
script.src = environment.service[scriptIn][lang];
document.head.appendChild(script);
}
}

script returns window object which needs to be loaded to get dynamic data which returns (window).data

when these two scripts are loaded in angular the first Script is getting overridden by second script

Am loading this scripts when app is initialized. Both of these script data needs to be rendered on same route

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!