Saltar al contenido

[Violation] El reflujo forzado al ejecutar JavaScript tomó un ejemplo de código de 41ms

Puede que se de el caso de que encuentres algún fallo en tu código o trabajo, recuerda probar siempre en un entorno de testing antes añadir el código al proyecto final.

Ejemplo: [violation] reflujo forzado al ejecutar javascript tomó

Update:Chrome58+ hid these and other debug messages by default.To display them click the arrow next to 'Info' and select 'Verbose'.Chrome57 turned on 'hide violations' by default.To turn them back on you need to enable filters and uncheck the 'hide violations' box.suddenly it appears when someone else involved in the project

I think it's more likely you updated to Chrome 56. This warning is a wonderful new feature, in my opinion, please only turn it off if you're desperate and your assessor will take marks away from you.The underlying problems are there in the other browsers but the browsers just aren't telling you there's a problem.TheChromium ticket is here but there isn't really any interesting discussion on it.These messages are warnings instead of errors because it's not really going to cause major problems.It may cause frames to get dropped or otherwise cause a less smooth experience.They're worth investigating and fixing to improve the quality of your application however.The way to dothis is by paying attention to what circumstances the messages appear, and doing performance testing to narrow down where the issue is occurring.The simplest way to start performance testing is to insert some code like this:functionsomeMethodIThinkMightBeSlow()const startTime =performance.now();// Do the normal stuff for this functionconst duration =performance.now()- startTime;console.log(`someMethodIThinkMightBeSlow took $durationms`);If you want to get more advanced, you could also use Chrome's profiler, or make use of a benchmarking library like this one.Once you've found some code that's taking a long time(50ms is Chrome's threshold), you have a couple of options:Cut out some/all of that task that may be unnecessary
Figure out how to do the same task faster
Divide the code into multiple asynchronous steps(1)and(2) may be difficult or impossible, but it's sometimes really easy and should be your first attempts.If needed, it should always be possible to do(3).Todothis 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);You can read more about the asynchronous nature ofJavaScript here.

Calificaciones y reseñas

Si tienes algún recelo o disposición de progresar nuestro noticia eres capaz de realizar un comentario y con mucho gusto lo observaremos.

¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)



Utiliza Nuestro Buscador

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *