UWInfo Blog
發表新文章
[Join] | [忘記密碼] | [Login]
搜尋

搜尋意見
文章分類-#Author#
[所有文章分類]
所有文章分類
  • ASP.NET (48)
  • ASP.NET2.0 (15)
  • ASP.NET4.0 (34)
  • JavaScript (49)
  • jQuery (26)
  • FireFox (4)
  • UW系統設定 (3)
  • SQL (39)
  • SQL 2008 (25)
  • mirror (4)
  • SVN (4)
  • IE (9)
  • IIS (20)
  • IIS6 (1)
  • 閒聊 (7)
  • W3C (6)
  • 作業系統 (9)
  • C# (24)
  • CSS (12)
  • FileServer (1)
  • HTML 5 (11)
  • CKEditor (3)
  • UW.dll (13)
  • Visual Studio (16)
  • Browser (8)
  • SEO (1)
  • Google Apps (3)
  • 網站輔助系統 (4)
  • DNS (5)
  • SMTP (4)
  • 網管 (11)
  • 社群API (3)
  • SSL (4)
  • App_Inventor (1)
  • URLRewrite (2)
  • 開發工具 (6)
  • JSON (1)
  • Excel2007 (1)
  • 試題 (3)
  • LINQ (1)
  • bootstrap (0)
  • Vue (3)
  • IIS7 (3)
  • foodpanda (2)
  • 編碼 (2)
  • 資安 (3)
  • Sourcetree (1)
  • MAUI (1)
  • CMD (1)
  • my sql (1)
最新回應
  • Newtonsoft.Json.JsonConvert.DeserializeObject 失敗的情況
    test...more
  • dotnet ef dbcontext scaffold
    ...more
  • [ASP.NET] 利用 aspnet_regiis 加密 web.config
    ...more
  • IIS ARR (reverse proxy) 服務安裝
    ...more
  • [錯誤訊息] 請加入 ScriptResourceMapping 命名的 jquery (區分大小寫)
    ...more
  • 用 Javascript 跨網頁讀取 cookie (Cookie cross page, path of cookie)
    ...more
  • 線上客服 - MSN
    本人信箱被盜用以致資料外洩,是否可以請貴平台予以協助刪除該信箱之使用謝謝囉...more
  • 插入文字到游標或選取處
    aaaaa...more
  • IIS 配合 AD (Active Directory) 認証, 使用 .Net 6.0
    太感謝你了~~~你救了我被windows 認證卡了好幾天QQ...more
  • PostgreSQL 的 monitor trigger
    FOR EACH ROW 可能要改為 FOR EACH STATEMENT ...more
標籤
  • response
  • ordermain
  • 56
  • -5103 UNIO
  • CK
  • 在 pdf 加浮水印
  • [U2]
  • postgre
  • 0
  • Button
  • lock
  • intlTelInp
  • injec
  • SQL
  • 5Ofq7MEc
  • -6734
  • tls
  • touch
  • -7418
  • svn lock
  • 出單機
  • html
  • replace212
  • C
  • 1
  • 0,
  • 102
  • 10
  • a
  • 瀏覽您的USB 裝置
  • load
  • HTTP 錯誤 40
  • iis 8.5
  • asp.net
  • AD
  • config
  • ping -n 25
  • -5421
  • 網址
  • CKED ORDER
  • en
  • ip[t]
  • IIS_IUSR
  • message
  • for
  • UNT
  • datetime
  • u8PyeQf9
  • SMTP
  • connection
搜尋 lazy 結果:
使用IntersectionObserver API 實作 Lazy load
過去都是使用 jquery lazy load js 來實作延遲載圖,
其運作原理是偵測scroll事件以及img物件的相對位置來決定要不要load圖片

現在有更簡單的方式,就是用 IntersectionObserver API 這個 Web標準
來偵測 img 物件是不是進入可視 webview 範圍
https://developers.google.com/web/updates/2016/04/intersectionobserver

document.addEventListener("DOMContentLoaded", function() {
var lazyImages = [].slice.call(document.querySelectorAll("img.lazy"));;

if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
    let lazyImageObserver = new IntersectionObserver(function(entries, observer) {
     entries.forEach(function(entry) {
        if (entry.isIntersecting) {
         let lazyImage = entry.target;
         lazyImage.src = lazyImage.dataset.src;
         lazyImage.srcset = lazyImage.dataset.srcset;
         lazyImage.classList.remove("lazy");
         lazyImageObserver.unobserve(lazyImage);
        }
     });
    });

    lazyImages.forEach(function(lazyImage) {
     lazyImageObserver.observe(lazyImage);
    });
}
//這裡可以加上else處理萬一瀏覽器不支援的狀況
});


網頁裡面只要用  <img data-src='圖片網址' class='lazy' />  就可以啦

IntersectionObserver API
目前 Can I Use 網站顯示大部分 browser 都支援,iOS safari 要 12.2 版才支援
應該可以放心使用


 
More...
darren, 2019/4/3 下午 07:48:07
LazyLoad設定問題
Lazy本身載入不是太大問題~
但是因為本身是使用網頁設計上架構會互相牽連~某些圖會出不來~
例如:
1. 原本要顯示的區塊是display:none,Lazyload為了效能問題,因此不顯示的圖片不會讀取。
2. 事件觸發是寫在Srcoll上面~因此某些圖片是用display切換的時候,不會出發Srcoll事件。
3. 大KV縮小的時候~不會觸發Scroll事件,因此圖片也不會讀出來~

因此在我們的 windowload事件
設定要加上一些參數
skip_invisible: false,                 display:none的圖片要讀;圖片若是到大視窗可視畫面時會觸發~
failure_limit: $("img.lazy").length,   容納錯誤次數,
threshold: 250                         圖片預讀高度,


參考連結:
http://www.appelsiini.net/projects/lazyload
http://localhost:2874/WWW20/scripts/Merge/lazyload.js
More...
Doug, 2014/4/9 上午 11:25:56
外掛 Lazy Load-延遲載入網頁圖片

資料來源:http://www.dotblogs.com.tw/demarco/archive/2010/08/03/16980.aspx

為了減輕server loading
圖片的顯示 加上了JQuery外掛 Lazy Load
讓圖片延遲載入

瀏覽器 拉到該可視範圍內
圖片才載入

前提必須有jquery

接著需下載
queryLoader.js
jquery.lazyload.mini.js

塞進所用呈現的檔案內

 <head>
  <title>test</title>
  <script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
  <link rel="stylesheet" href="queryLoader.css" type="text/css" />
  <script type='text/javascript' src='jquery.lazyload.mini.js'></script>
</head>

並加上

 <script type="text/javascript">
  $("img").lazyload({ effect: "fadeIn" });
</script>


img就是html的

<img src="/images/001.gif" />


下載Lazy Load網址:http://www.appelsiini.net/projects/lazyload

More...
Reiko, 2012/3/28 下午 02:23:40
~ Uwinfo ~