Book Image

jQuery Mobile Cookbook

By : Chetan Jain
Book Image

jQuery Mobile Cookbook

By: Chetan Jain

Overview of this book

jQuery Mobile is an award winning, HTML5/CSS3 based open source cross-platform UI framework. It offers a very cool and highly customizable UX. It is built on the popular jQuery library and uses declarative coding making it easy to use and learn. It is the market leader today considering the numerous browsers and platforms that it supports."jQuery Mobile Cookbook" presents over a hundred recipes written in a simple and easy manner. You can quickly learn and start writing code immediately. Advanced topics such as using scripts to manipulate, customize, and extend the framework are also covered. These tips address your common everyday problems. The book is very handy for both beginner and experienced jQuery Mobile developers.You start by developing simple apps using various controls and learn to customize them. Later you explore using advanced aspects like configurations, events, and methods.Develop single and multi-page applications. Use caching to boost performance. Use custom transitions, icon sprites, styles, and themes. Learn advanced features like configurations, events, and methods. Explore future trends by using HTML5 new features and semantics with jQuery Mobile."jQuery Mobile Cookbook" is an easy read and is packed with practical tips and screenshots.
Table of Contents (19 chapters)
jQuery Mobile Cookbook
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Prefetching pages for faster navigation


Using a single-page template for your mobile app makes your mobile app faster and lighter. But you have to fetch each page during navigation. You can see the ui-loader spinning icon every time a page loads. This problem does not happen with a multi-page template application, as all the pages are already preloaded into the DOM. By using the prefetch feature, a single-page template application can be made to mimic the multi-page template application.

A page marked for prefetch is loaded in the background and is immediately available when the user tries to open it. You can prefetch pages in two ways. The first is by just adding the data-prefetch attribute to the anchor link. The second way is by using JavaScript to call the loadPage() method. This recipe shows you how to improve page loading speed by prefetching pages in your jQuery Mobile app.

Getting ready

Copy the full code of this recipe from the code/02/prefetch sources folder. You can launch this...