O'Reilly logo

Mobile Web Performance Optimization by S. Niranga

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to optimize JavaScript

Nowadays, we use JavaScript in our application or website to create visual effects. Sometimes, it creates these visual effects by manipulating styles or doing calculations such as sorting or searching. However, if we don't use these properly, JavaScript can cause performance issues on our website or application. To minimize these impacts on the website, you should consider the following:

  • Avoid using setTimeout or setInterval for visual updates. Instead of these you can use requestAnimationFrame.
  • Move long-running JavaScript main thread to Web workers.
  • Use browser development tools to profile JavaScript and assess the impact.
  • Use micro-tasks to make DOM changes rather than using several frames.
  • Keep your HTML code clean by ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required