Violation Long running JavaScript task took xx ms

0 votes

It's the first time I've ever received this type of warning, which I received recently:

[Violation] Long running JavaScript task took 234ms
[Violation] Forced reflow while executing JavaScript took 45ms

As a member of a team working on a project, I have no idea where this is coming from. 

Never previously has this occurred. 

It arose out of nowhere when another person joined the endeavor. 

How can I determine which file or function generated this warning? 

I've been searching for the response, but primarily for a way to approach the problem. 

If I can't even identify the root of the issue, I can't fix it.

In this instance, only Chrome receives the warning. 

Although I attempted to use Edge, I received no identical alerts, and I haven't yet tried it on Firefox.

I also experience the following jquery.min.js error:

[Violation] Handler took 231ms of runtime (50ms allowed)            jquery.min.js:2
Nov 14, 2022 in Java by Nicholas
• 7,760 points
4,287 views

1 answer to this question.

0 votes

These messages are classified as warnings rather than errors because they are unlikely to cause major issues. It may result in dropped frames or a less smooth experience.

They are, however, worth investigating and correcting in order to improve the quality of your application. This can be accomplished by paying attention to the circumstances under which the messages appear and performing performance testing to pinpoint the source of the problem. To begin performance testing, simply insert the following code:

function someMethodIThinkMightBeSlow() {
    const startTime = performance.now();

    // Do the normal stuff for this function

    const duration = performance.now() - startTime;
    console.log(`someMethodIThinkMightBeSlow took ${duration}ms`);
}

Once you've identified some code that's taking a long time (50ms is Chrome's threshold), you have two options:

1. Remove some or all of the tasks that are potentially unnecessary.
2. Determine how to complete the same task in less time.
3. Divide the code into multiple asynchronous steps 
(1) and (2) may be difficult or impossible, but they are sometimes really easy and should be your first attempts. If necessary, it should always be possible to do so (3). You will use something like:

setTimeout(functionToRunVerySoonButNotNow);

or

// This one is not available natively in IE, but there are polyfills available.
Promise.resolve().then(functionToRunVerySoonButNotNow);
answered Nov 15, 2022 by Damonlang
• 1,230 points

Related Questions In Java

0 votes
2 answers

I'm getting following error, while i'm running code in windows xp service pack 3 with JDK 6 version.

Till you send the code, I would ...READ MORE

answered May 16, 2018 in Java by Meci Matt
• 9,460 points
2,737 views
0 votes
1 answer

Retrieving the path of a running jar file

Its quite simple. Try using the below ...READ MORE

answered May 25, 2018 in Java by geek.erkami
• 2,680 points
10,739 views
0 votes
2 answers

When I am running eclispe on my computer it is throwing error. How to resolve it?

If you have downloaded the 64 bit ...READ MORE

answered Dec 10, 2018 in Java by Sushmita
• 6,920 points
1,079 views
0 votes
1 answer

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK

In your Eclipse IDE, go into Window > Preferences > Java > Installed JREs > ...READ MORE

answered Jun 18, 2018 in Java by Parth
• 4,640 points
3,393 views
0 votes
0 answers

Chrome extension HTML Tree Generator is not working

I installed HTML Tree Generator to observe ...READ MORE

Jul 27, 2022 in HTML by Tejashwini
• 3,820 points
1,320 views
0 votes
1 answer

Cannot open local file - Chrome: Not allowed to load local resource

To answer your query, start with opening ...READ MORE

answered Feb 18, 2022 in Java by Aditya
• 7,680 points
9,044 views
0 votes
0 answers

Canonical updated with JS - is this used by SEO?

0 Due to some hindrance by BigCommerce, I ...READ MORE

Mar 6, 2022 in Digital Marketing by Kichu
• 19,040 points
1,473 views
0 votes
0 answers

Uncaught TypeError: Cannot read property 'top' of undefined

I have two different kinds of sticky ...READ MORE

May 11, 2022 in Java-Script by Kichu
• 19,040 points
3,418 views
0 votes
1 answer

Check if input is number or letter javascript

The isNaN function can be used to ...READ MORE

answered Nov 15, 2022 in Java by Damonlang
• 1,230 points
1,404 views
0 votes
1 answer

How to draw a circle in HTML5 Canvas using JavaScript?

Here's how to draw a circle in ...READ MORE

answered Nov 15, 2022 in Java by Damonlang
• 1,230 points
968 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP