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

103
Views
jQuery.getScript does not work with jQuery Version 3.x

I'm reloading/re-executing my javascript using jquery's getScript function with

 jQuery('#my-script').empty();
  jQuery.getScript( 'js/myscript.js', function() { 
  });

This worked fine with jquery V1.x or V2.x. Since jquery v3.x the reload works but the re-execute of script fails with error

uncaught SyntaxError: redeclaration of let varname

where "varname" is a class like

class varname {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }  
  method1 { .. }  
  }

I think the problem is caused by the ES6 Javascript standard. But I could not find a solution to fix my problem other than use the older jquery versions. Has anybody a clue how to solve this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I've solved the problem - it is caused by ES6 standard, which changes the process of scoping of variables. I had to define my classes as:

var varname = class varname {...}

This solved the issue. Just defining

class varname {...}

will result in a definition of.

let varname = class varname {...}

and this wil cause a failed redeclaration.

about 4 years ago · Juan Pablo Isaza Report
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!