Implementation Code of Textarea and lazy Rendering

Source: Internet
Author: User

The Code is as follows.
Copy codeThe Code is as follows:
<Div>
Render content now
<Ul>
<Li> Zhang San </li>
<Li> Zhang Si </li>
</Ul>
</Div>
<Div>
<Textarea id = "lazyRender01" style = "display: none">
Lazy rendering content
<Ul>
<Li> li San </li>
<Li> li Si </li>
</Ul>
</Textarea>
</Div>
<Script>
SetTimeout (function () {// lazy Rendering
Var el = document. getElementById ('lazyrender01 ');
El. parentNode. innerHTML = el. value;
},1000 );
</Script>

The benefit of the Code is: let the content corresponding to Li San and Li Si, before lazy rendering, do not form dom nodes, do not request images.
Some students asked: "The content in Textarea is unfriendly to search engines ."
No problem. This is also a good solution:
Copy codeThe Code is as follows:
<Div>
Render content now
<Ul>
<Li> Zhang San </li>
<Li> Zhang Si </li>
</Ul>
</Div>
<Div>
<Script> document. write ('<textarea id = "lazyRender01" style = "display: none">'); </script>
Lazy rendering content
<Ul>
<Li> li San </li>
<Li> li Si </li>
</Ul>
</Textarea>
</Div>
<Script>
SetTimeout (function () {// lazy Rendering
Var el = document. getElementById ('lazyrender01 ');
El. parentNode. innerHTML = el. value;
},1000 );
</Script>

The difference between the code is very simple, but the '<textarea id = "lazyRender01">' section is output through document. write in js.
But the results are quite different: even if the browser does not support js, everything can still be displayed as is.

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.