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:
650) this.width=650; "Src=" http://img.blog.csdn.net/20140505144128093?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvzgf3yw5nyw5iyw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "style=" border:0px; "/>
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.
650) this.width=650; "Src=" http://img.blog.csdn.net/20140505144819734?watermark/2/text/ ahr0cdovl2jsb2cuy3nkbi5uzxqvzgf3yw5nyw5iyw4=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/ Southeast "style=" border:0px; "/>
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 plain copy
Print? 650) this.width=650; "src=" Https://code.csdn.net/assets/CODE_ico.png "alt=" on Code View "Width=" "height=" 12 " Style= "border:0px;"/>650) this.width=650; "src=" Https://code.csdn.net/assets/ico_fork.svg "alt=" Derivation to My Code slice " Width= "height=" style= "border:0px;"/>
<! DOCTYPE HTML>
<html>
<head>
<title> Practice </title>
<Meta charset="Utf-8">
<Meta name="viewport" content= "width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=0; " />
<link href="css/jquery.mobile-1.0.1.min.css"
rel= "stylesheet" type="text/css"/>
<script src="js/jquery-1.6.4.js"
type="Text/javascript" ></script>
<script src="js/jquery.mobile-1.0.1.js"
type="Text/javascript" ></script>
</head>
<body>
<div id="page_pagetransition" data-role="page" data-dom-cache="true">
<header data-role="header">
<H1> prefetch page processing </H1>
</Header>
<div class="content" data-role="Content">
<p> This demo will present two ways to switch pages with and without prefetching techniques. </P>
<a href="prefetchpage01.html" Data-prefetch> page with prefetch technology </a> <br/>
<a href="prefetchpage02.html" rel="external"> traditional page Jump implementation </a>
</div>
</div>
</body>
</html>
Prefetchpage01.html
[HTML] view plain copy
Print? 650) this.width=650; "src=" Https://code.csdn.net/assets/CODE_ico.png "alt=" on Code View "Width=" "height=" 12 " Style= "border:0px;"/>650) this.width=650; "src=" Https://code.csdn.net/assets/ico_fork.svg "alt=" Derivation to My Code slice " Width= "height=" style= "border:0px;"/>
<section id="Page_pagetransition2" data-role="page">
<header data-role="header">
<H1> page jump </H1>
</Header>
<div class="content" data-role="Content">
<p> skip to Pre-fetching page </P>
</div>
</Section>
Prefetchpage02.html
[HTML] view plain copy
Print? 650) this.width=650; "src=" Https://code.csdn.net/assets/CODE_ico.png "alt=" on Code View "Width=" "height=" 12 " Style= "border:0px;"/>650) this.width=650; "src=" Https://code.csdn.net/assets/ico_fork.svg "alt=" Derivation to My Code slice " Width= "height=" style= "border:0px;"/>
<! DOCTYPE HTML>
<html>
<head>
<title> Practice </title>
<Meta charset="Utf-8">
<Meta name="viewport" content= "width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=0; " />
<link href="css/jquery.mobile-1.0.1.min.css"
rel= "stylesheet" type="text/css"/>
<script src="js/jquery-1.6.4.js"
type="Text/javascript" ></script>
<script src="js/jquery.mobile-1.0.1.js"
type="Text/javascript" ></script>
</head>
<body>
<section id="Page_pagetransition3" data-role="page">
<header data-role="header">
<H1> page jump </H1>
</Header>
<div class="content" data-role="Content">
<p> skip to the traditional jquery mobile page </P>
</div>
</Section>
</body>
</html>
HTML5 Mobile Development Road (Wuyi)--jquerymobile improve page access speed