当前位置:网站首页>DOM -- preloading and lazy loading
DOM -- preloading and lazy loading
2022-07-22 01:03:00 【ca11meback】
Preloading : It literally means to load in advance —— Optimization of homologous loading ( It is often used for loading sprite graphs )
Lazy loading : Load only when certain conditions are triggered
Preloading has nothing to say , The point to note is , Observe network Number of network requests , After preloading, no network requests will be made later , But this is under our control , stay src Adding a time object to an attribute is different , Need to load multiple times .
window.onload=function(){
document.onscroll=function(e){
let top=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop
let h=cHeight =window.innerHeight||document.body.clientHeight;
console.log(top,img2.offsetTop-h-100)
if(top>=(img2.offsetTop-h-100)){
console.log(33333333333)
img2.src=img2.dataset.src1
}
}
}
This is a lazy load , Wait until the slider slides to a certain position before loading the picture top Is the distance that has been pulled down
Why subtract one -h Well ? Because it is the height of the page that is not subtracted until the set position. It takes an extra screen distance to trigger , It means calculated from the top of the current page . final 100 It is the time you control when you want to load .
边栏推荐
- dom——页面的渲染过程
- Using fromquest in a scratch
- Considérations relatives à la référence de la bibliothèque externe par Visual Studio
- Hcip day 2 operation 7.17
- The only "magic weapon" of enterprise operation and management: data center supported by technical capability matrix
- Temperature signal measurement K-type thermocouple signal collector rs485/232 remote IO conversion module
- NAOMI代码详解
- 丽华快餐订餐小程序
- 类模板重载输出运算符报错
- Take the interface test in 2 hours - dark horse programmer, master the preparation of interface use cases, interface information analysis, interface information analysis through Oh packet capturing, a
猜你喜欢
赫斌C语言全案文,自用笔记,给后来者一点思路
Low code tool revolution on the cusp of the storm
[AR Foundation] AR Foundation基礎
If else: is there a clock cycle difference between the judgment statement and the execution statement? Parallel execution? Is there a priority?
the volume for a file has been externally altered so that the opened file is no longer valid
A simple way to get headers and cookies
Strategy Center -- the brain for enterprises to build digital intelligence operation platform
Integer bisection, floating-point bisection and bisection function (lower_bound(), upper) in STL_ bound())
Ultra high precision UWB is not expensive -- detailed explanation of UWB positioning base station cost
Temperature signal measurement K-type thermocouple signal collector rs485/232 remote IO conversion module
随机推荐
hcip第九天
【数据分析01】
Number of columns in MySQL statistics table
Integer bisection, floating-point bisection and bisection function (lower_bound(), upper) in STL_ bound())
Web自动化处理“滑动验证码”
dom——style的操作
Bank compliance procedures KYC, CDD, AML and TM
从0到1 拿下C语言—程序结构及使用示例
ospf综合实验
mgre与ospf综合实验
Precautions for visual studio to reference external libraries
记一次网站渗透的漏洞挖掘记录
OpenShift 4 - 安装 ODF 并部署红帽 Quay (3 Worker)
Centos7在线安装MySQL
Cloud native and low code platforms make agile enterprises
How will Import SQL file into MySQL
Mobile app capture tool mobile selenium - appium, mitmdump mobile capture
Comprehensive experiment of mGRE and OSPF
NAOMI代码详解
A simple and easy-to-use translation program