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

367
Views
What is @babel/plugin-transform-classes?

I run Google PageSpeed Insights on my site, and it reports an issue that is "Avoid serving legacy JavaScript to modern browsers", as below:

enter image description here

I have no idea of what is @babel/plugin-transform-classes, so I search online and it seems babel is a JavaScript compiler and @babel/plugin-transform-classes is a plugin.

But I don't know or install the compiler and the plugin, why there will be such an issue?

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

0

Short answer

  • A babel plugin that fix some Javascript errors for legacy browser
  • You cannot fix this error on your own, not if you're using Wordpress or any framework at least.

Long answer

What is babel

Babel is a JavaScript compiler which is used by framework to make code understandable for older browser.

What is @babel/plugin-transform-classes

This is a babel plugin, which is included in @babel/preset-env.

It does

  • Transpiles classes using SuperClass.apply(/* ... */), but native classes aren't callable and thus throw in this case.
  • Some built-in functions (like Array) always return a new object. Instead of returning it, Babel should treat it as the new this.

In

class Test {
  constructor(name) {
    this.name = name;
  }

  logger() {
    console.log("Hello", this.name);
  }
}

Out

function _classCallCheck(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
}

var Test = (function() {
  function Test(name) {
    _classCallCheck(this, Test);

    this.name = name;
  }

  Test.prototype.logger = function logger() {
    console.log("Hello", this.name);
  };

  return Test;
})();

Can I fix this problem on my own?

No, since a lot of library are still using babel, you'll have to wait for them to move on.

So you're safe to ignore this issue.

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!