728x90
반응형
Delayed (Lazy) Loading in HTML by JavaScript (+jQuery)
This is sometimes called 'Lazy Loading'. Maths, i.e. equations, are also delayed-rendered by MathJax . (Some of this document are written in Korean (called Hangul). People who do not know Hangul, just read english part. That will be enough.) 사용자가 안보고 넘길것 같은 부분은 굳이 미리 로딩해놓지 말고, 속도를 빠르게, 서버 부담을 적게 덜어주자는 목적으로 Delayed Loading이라는 개념이 있음. 특히나 용량이 큰 이미지나 동영상을 이렇게 처리해주면 좋은듯 .
If you click DocuK Log: button, DocuK Script Log printed will appear at right-bottom. Bug report or any improvement suggestion is always welcome. I set
kipid.delayPad=0;
(px) and kipid.wait=2000;
(msec) in this document. Reduce kipid.wait
(ms) and change kipid.delayPad
when you actually implement it. I set big value to show the delayed-load apprently.
Usually I set
kipid.delayPad=3000;
(px) and kipid.wait=2000;
(sec) in common documents including many maths and images.
Tested in Chrome (+Android Smartphone), IE, and FireFox browsers at 2014-05-29. (Chrome gave the best performance. IE was the worst.)
Table of Contents
Delayed(Lazy)-Loading: Images, Videos, Maths and possibly Graphs
imgs or iframes with delayed-src attribute (:
<img delayed-src="image file path">
, <iframe delayed-src="url to load">
), divs with delayed-bgimage (:<div delayed-bgimage="image file path" style="background-repeat:no-repeat; background-attachment:fixed; background-position:center"></div>
) will be delayed-loaded.
Graphs or Charts by JavaScript can also be delayed-loaded by window's "on scroll" event. But not implemented yet here.
HTML source example
The below source is actually implemennted in section . This code below is automatically copied by JavaScript from that section for the display.
Delayed-Loading JavaScript code (by kipid)
Code is updated at 2014-06-12. MathJax maths are also delayed-loaded. Ctrl+F "// Delayed Loading." will be helpful.
Inside
<script src="http://cfs.tistory.com/custom/blog/146/1468360/skin/images/docuK-min.js"></script>
is there a script code related to the delayed loading. Unrelated codes are cut for the sake of simplicity. Full code is available in .
Old version without delayed MathJax rendering
I got some ideas mainly from the code posted in , and got helped from . Thanks.
Implemented example of Delayed Loading
div with delayed-bgimage
This is an image with delayed-src. and .
div with delayed-bgimage again
This is an image with delayed-src.
References and Related Articles
- kipid's blog - Improving web performance; Delayed loading 및 다른 web page optimization들 관련.
- pamela fox's blog - Improving front page performance: removing images, 5 ways, 2014-01-30; TinyPNG로 이미지 용량줄이기, Delay load로 scroll 되기 전의 load 줄이기.
- 인터넷, Web, HTML, 블로그에서 수식 사용하기 (Equation or math in HTML, blog)
- kipid's blog - HTML docuK format ver. 2.1
- kipid's blog - docuK short copiable version
- github.com - kipid - docuK
- jQuery.com; and jQuery - download;
// JavaScript enhancer - MathJax.org; and MathJax Documentation - latest; and The Core Configuration Options; and The MathJax.Hub Object;
// Math renderer. - Google Code Prettify and Getting Started;
// Code prettyfier. - MDN docs - CSS - background
- jQuery.com - API - on(); and off() and scroll()
- What is _.defer and _.throttle in JavaScript?, 2014-05-28, asked by kipid (me);
- w3schools.com - CSS Selector Reference; and MDN guide - CSS - Selectors; You can add a default background to delayed elements using css like "
img[delayed-src], iframe[delayed-src], div[delayed-bgimage] {background:url(defaultBg.jpg);}
". This will be automatically replaced. - MathJax.org - Beautiful math in all browsers; and
Getting started; and
Loading and Configuring MathJax; and
The Core Configuration Options; and
Terms of service;
and MathJax Documentation - latest; and The Core Configuration Options; and The MathJax.Hub Object;
// LaTeX 형태의 수식도 표현해주고 MathML 형태의 수식(Mathematica랑 MS word 등에서 쓰이는 수식 code인듯? more machine-readable이라고. 최신 browser에서 MathML은 자동으로 처리해주는듯도. HTML/XML이랑 비슷한.), AsciiMath도 표현해 준다고 함.
// CodeCogs보다 옵션들도 많고 더 좋아보이기도 하는데, 제대로 사용하려면 JavaScript도 어느정도는 알아야하고 공부가 조금 필요한듯.
Promoting image:
Related Posts
docuK
Supported by
Related API Documentations
728x90
반응형
'[IT/Programming] > HTML related' 카테고리의 다른 글
LaTeX(라텍스, 레이텍) 소개 및 설명서(Guide)들 (0) | 2019.03.04 |
---|---|
CSS3 examples (0) | 2019.03.04 |
괜찮은 에디터들 소개 및 추천 (Introducing/Recommending good code editors) (2) | 2019.03.04 |
Cloud Server Services (eg. Amazon Web Services) (0) | 2019.02.22 |
HTTP Server-side Frameworks/Languages 뭘 써야할까? (0) | 2019.02.19 |
CSS Specificity or Priority (우선순위) (0) | 2019.02.19 |
Youtube Download (0) | 2019.02.18 |