Book Image

Mastering jQuery

By : Alex Libby
Book Image

Mastering jQuery

By: Alex Libby

Overview of this book

<p>Mastering jQuery has been written not only to help maximize your skills with core functionality in the library, but also to explore some of the more intriguing ways of using the library to achieve real-world solutions that could feature on any website or online environment.</p> <p>You'll start with a look at some of the more advanced ways to incorporate the library into your pages, followed by working with forms and advanced form validation using regular expressions. Next you'll move on to animating in jQuery, advanced event handling, and using jQuery effects.</p> <p>Finally, you will develop practical examples of using jQuery with external functionality such as node-webkit, before finishing with a session on optimizing your version of the library for maximum efficiency and exploring best practices for using QUnit.</p>
Table of Contents (21 chapters)
Mastering jQuery
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Improving the speed of loading data with static sites


Now that we have seen an AJAX example in action, it may surprise you to learn that the code used isn't technically as efficient as it could be, even with the small amount of text that we displayed on screen.

Huh? I hear you ask – surely we can't really improve on such a simple demo, right? Well, strange as it might seem, we can already make one improvement. Let's take a look at some of the tricks we can use to reduce any slowness in our code – not all of them have to do with simply changing our code:

  • Reduce the number of AJAX requests – no, I've not lost the plot; improving our code isn't always about making changes to the code itself! If we consider when each AJAX request is made, there may be opportunities to reduce the number, if reordering means we can achieve the same result. For example, if we have AJAX requests being made on a timer, we can set a flag to indicate that AJAX requests should only be performed in changes have been made...