Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mobile Web Performance Optimization

You're reading from   Mobile Web Performance Optimization Deliver a better mobile user experience by improving and optimizing your website – follow these practical steps for cutting-edge application development

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781785289972
Length 150 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
S. S. Niranga S. S. Niranga
Author Profile Icon S. S. Niranga
S. S. Niranga
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Pillars of Mobile Web Performance Optimization 2. Mobile Web Optimization Essentials FREE CHAPTER 3. How to Optimize Your Mobile Website 4. Caching and Optimizing 5. Monitoring and Debugging Our Website 6. Managing Third-Party Components 7. Tips and Tricks Index

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 removing unwanted DIV and SPAN tags.

  • When updating styles, do them as a batch.

  • Build DOM separately, before it is added to the page.

  • Remember to unbind events when they are no longer needed.

  • Learn about event bubbling. Use jQuery.bind() instead of jQuery...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image