HTML5 Mobile Development Road (Wuyi)--jquerymobile improve page access speed

Source: Internet
Author: User
Tags prefetch

This paper is the official HTML5 training course for Brother Lian it education organization, mainly introduces: HTML5 Mobile Development Road (Wuyi)--jquerymobile improve page access speed

When using jquery Mobile for development, you can choose a single-page template and a multi-page template, when you use a single-page template to jump from one page to another page when you need to request from the server, the user will feel a slight pause. With multi-page templates, you can improve the smoothness of page jumps, but multiple pages are downloaded at once, so the download time becomes longer and the user experience is affected.

In the development of prefetch-based technology, when the first page's Dom object is loaded, JQuery Mobile will prefetch the linked address of the tag data-prefetch. The detailed procedure for prefetching is as follows:

Note: When using prefetch, it is not recommended to add the Data-prefetch property to all links, because too many Data-prefetch properties cause the mobile device to prefetch too many pages, loading DOM objects too large, causing phone memory consumption, some phones running slowly or even crashing.

In order to effectively save the memory resources of the mobile device browser, the page without tag cache will be cleared when the next page is accessed.

If you do not want to clean up the previous page in the browser cache, you can add Data-dom-cache= "true" on the corresponding DOM object, there is a better way to use the HTML5 offline application function to cache the content of the page locally.

The relevant sample code is as follows:

[HTML]View PlainCopyprint?
  1. <! DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title> Practice </title>
  5. <Meta charset="Utf-8">
  6. <Meta name="viewport" content= "width=device-width,
  7. initial-scale=1.0, maximum-scale=1.0, user-scalable=0; " />
  8. <link href="css/jquery.mobile-1.0.1.min.css"
  9. rel= "stylesheet" type="text/css"/>
  10. <script src="js/jquery-1.6.4.js"
  11. type="Text/javascript" ></script>
  12. <script src="js/jquery.mobile-1.0.1.js"
  13. type="Text/javascript" ></script>
  14. </head>
  15. <body>
  16. <div id="page_pagetransition" data-role="page" data-dom-cache="true">
  17. <header data-role="header">
  18. <H1> prefetch page processing </H1>
  19. </Header>
  20. <div class="content" data-role="Content">
  21. <p> This demo will present two ways to switch pages with and without prefetching techniques. </P>
  22. <a href="prefetchpage01.html" Data-prefetch> page with prefetch technology </a>< br/>
  23. <a href="prefetchpage02.html" rel="external"> traditional page Jump implementation </A >
  24. </div>
  25. </div>
  26. </body>
  27. </html>

Prefetchpage01.html

[HTML]View PlainCopy print?
  1. <section id="Page_pagetransition2" data-role="page">
  2. <header data-role="header">
  3. <H1> page jump </H1>
  4. </Header>
  5. <div class="content" data-role="Content">
  6. <p> skip to Pre-fetching page </P>
  7. </div>
  8. </Section>

Prefetchpage02.html

[HTML]View PlainCopy print?
  1. <! DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title> Practice </title>
  5. <Meta charset="Utf-8">
  6. <Meta name="viewport" content= "width=device-width,
  7. initial-scale=1.0, maximum-scale=1.0, user-scalable=0; " />
  8. <link href="css/jquery.mobile-1.0.1.min.css"
  9. rel= "stylesheet" type="text/css"/>
  10. <script src="js/jquery-1.6.4.js"
  11. type="Text/javascript" ></script>
  12. <script src="js/jquery.mobile-1.0.1.js"
  13. type="Text/javascript" ></script>
  14. </head>
  15. <body>
  16. <section id="Page_pagetransition3" data-role="page">
  17. <header data-role="header">
  18. <H1> page jump </H1>
  19. </Header>
  20. <div class="content" data-role="Content">
  21. <p> skip to the traditional jquery mobile page </P>
  22. </div>
  23. </Section>
  24. </body>
  25. </html>

HTML5 Mobile Development Road (Wuyi)--jquerymobile improve page access speed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.