TW202524335A - Web font loading optimization method and system - Google Patents
Web font loading optimization method and system Download PDFInfo
- Publication number
- TW202524335A TW202524335A TW112148361A TW112148361A TW202524335A TW 202524335 A TW202524335 A TW 202524335A TW 112148361 A TW112148361 A TW 112148361A TW 112148361 A TW112148361 A TW 112148361A TW 202524335 A TW202524335 A TW 202524335A
- Authority
- TW
- Taiwan
- Prior art keywords
- font
- web
- subset
- server
- webpage
- Prior art date
Links
Landscapes
- Computer And Data Communications (AREA)
Abstract
Description
本發明一般涉及網頁開發,更具體地說,涉及一種在網頁瀏覽器中優化網頁字型加載的方法和系統。The present invention relates generally to web page development and, more particularly, to a method and system for optimizing web page font loading in a web browser.
在現代網頁開發中,網頁字型已成為網站設計的重要部分,使得用戶體驗更具視覺吸引力和個性化。然而,使用網頁字型也帶來了自己的一套挑戰,特別是在加載速度和性能方面。傳統的網頁字型加載方法可能會拖慢網頁渲染速度,對用戶體驗產生負面影響,並可能增加跳出率。 在I427534這篇專利中,其所接露的網頁字型加載方法包括以下步驟: 1. 用戶的瀏覽器向目標網頁伺服器請求網頁資源。 2. 網頁伺服器將網頁和相關資源,包括一個網頁字型腳本,下載到用戶的瀏覽器。 3. 下載後,網頁字型腳本運行並確定網頁所需的字符集。 4. 網頁字型腳本向網頁字型伺服器請求所需的字型子集。 5. 網頁字型伺服器在收到請求後生成所需的字型子集。 6. 網頁字型伺服器將生成的字型子集的地址傳送到用戶的瀏覽器。 7. 用戶的瀏覽器根據收到的地址將字型子集應用於網頁文本。 雖然這種方法是可行的,但它有幾個缺點。例如,每次加載網頁時,即使內容沒有變化,網頁字型伺服器也必須重新生成字型子集,導致不必要的計算開銷和加載時間增加。對於內容在多次訪問中保持不變的靜態網站來說,這種方式特別低效。 In modern web development, web fonts have become an important part of website design, making the user experience more visually appealing and personalized. However, using web fonts also brings its own set of challenges, especially in terms of loading speed and performance. Traditional web font loading methods may slow down web page rendering, have a negative impact on user experience, and may increase bounce rate. In the patent I427534, the web font loading method disclosed includes the following steps: 1. The user's browser requests web page resources from the target web server. 2. The web server downloads the web page and related resources, including a web font script, to the user's browser. 3. After downloading, the web font script runs and determines the character set required for the web page. 4. The web font script requests the required font subset from the web font server. 5. The web font server generates the required font subset upon receiving the request. 6. The web font server sends the address of the generated font subset to the user's browser. 7. The user's browser applies the font subset to the web page text based on the received address. Although this approach works, it has several disadvantages. For example, the web font server must regenerate the font subset every time the web page is loaded, even if the content has not changed, resulting in unnecessary computational overhead and increased loading time. This approach is particularly inefficient for static websites whose content remains unchanged across multiple visits.
因此,本發明的其中一目的主要解決的問題是傳統網頁字型加載過程中的低效和冗餘。具體來說,本發明旨在通過減少冗餘的字型子集生成來優化該過程,從而提高網頁加載速度和整體用戶體驗。 基於上述目的與其他目的,本發明提出了一種新穎的方法和系統,用於在網頁瀏覽器中優化網頁字型的加載,從而提高網頁渲染的效率並改善整體用戶體驗。該發明通過引入一種雜湊機制來解決傳統網頁字型加載技術的限制,該雜湊機制消除了對於靜態網站(其中內容在多次訪問中保持不變)的冗餘字型子集生成的需求。 在提出的方法中,當用戶請求一個網頁時,運行在用戶瀏覽器上的網頁字型腳本會根據網頁所需的字符集和字型資訊計算一個雜湊值。該雜湊值是使用如MD5或SHA-2等加密雜湊演算法生成的。然後,網頁字型腳本向網頁字型伺服器發送請求,請求一個與生成的雜湊值相對應的字型子集。如果伺服器返回一個檔案,則表示已經存在一個與雜湊值匹配的字型子集,無論是因為它已經被先前加載過,還是因為網頁內容沒有變化。在這種情況下,伺服器返回現有字型子集的地址,然後瀏覽器將其應用於網頁文本。 如果網頁字型伺服器返回一個空值,則表示在網頁字型伺服器上不存在與雜湊值匹配的字型子集。在這種情況下,網頁字型伺服器會根據網頁字型腳本發送的字符集和字型資訊生成一個新的字型子集。然後,這個新生成的字型子集會與其對應的雜湊值一起存儲在網頁字型伺服器上,使其可以供未來的請求使用。然後,網頁字型伺服器將新生成的字型子集的地址返回給瀏覽器,瀏覽器將其應用於網頁文本。其中,所述字符集為去除重複字符後的資料。 通過採用這種基於雜湊的方法,該發明顯著減少了與網頁字型加載相關的計算開銷,特別是對於靜態網站。該發明設計為可以輕易地整合到現有的網頁開發框架中,並且與各種加密雜湊演算法兼容,提供了靈活性和可擴展性。 為讓本發明之上述特徵和優點能更明顯易懂,下文特舉較佳實施例,並配合所附圖式,作詳細說明如下。 Therefore, one of the purposes of the present invention is to mainly solve the problem of inefficiency and redundancy in the traditional web font loading process. Specifically, the present invention aims to optimize the process by reducing redundant font subset generation, thereby improving web page loading speed and overall user experience. Based on the above and other purposes, the present invention proposes a novel method and system for optimizing web font loading in a web browser, thereby improving the efficiency of web page rendering and improving the overall user experience. The invention solves the limitations of traditional web font loading technology by introducing a hashing mechanism that eliminates the need for redundant font subset generation for static websites (where the content remains unchanged across multiple visits). In the proposed method, when a user requests a web page, a web font script running on the user's browser calculates a hash value based on the character set and font information required by the web page. The hash value is generated using a cryptographic hashing algorithm such as MD5 or SHA-2. The web font script then sends a request to the web font server for a font subset that corresponds to the generated hash value. If the server returns a file, it means that a font subset that matches the hash value already exists, either because it has been loaded previously or because the web page content has not changed. In this case, the server returns the address of the existing font subset, and the browser then applies it to the web page text. If the web font server returns a null value, it means that there is no font subset matching the hash value on the web font server. In this case, the web font server generates a new font subset based on the character set and font information sent by the web font script. Then, this newly generated font subset is stored on the web font server together with its corresponding hash value, making it available for future requests. The web font server then returns the address of the newly generated font subset to the browser, and the browser applies it to the web page text. Among them, the character set is the data after removing duplicate characters. By adopting this hash-based method, the invention significantly reduces the computational overhead associated with web font loading, especially for static websites. The invention is designed to be easily integrated into the existing web development framework and is compatible with various encryption hashing algorithms, providing flexibility and scalability. In order to make the above features and advantages of the invention more obvious and easy to understand, the following is a detailed description of the preferred embodiment with the accompanying drawings.
參照本文闡述的詳細內容和附圖說明是最好理解本發明。下面參照附圖會討論各種實施例。然而,本領域技術人員將容易理解,這裡關於附圖給出的詳細描述僅僅是為了解釋的目的,因為這些方法和系統可超出所描述的實施例。例如,所給出的教導和特定應用的需求可能產生多種可選的和合適的方法來實現在此描述的任何細節的功能。因此,任何方法可延伸超出所描述和示出的以下實施例中的特定實施選擇範圍。 請參照圖1A與圖2,圖1A所繪示為本發明之網頁字型加載優化系統之其中一實施例的方塊圖,圖2所繪示為本發明之網頁字型加載優化方法之流程圖。網頁字型加載優化系統100包括多個元件,每個元件在過程中都扮演著不同的角色。該網頁字型加載優化100包括一個網頁伺服器110、一個網頁字型腳本132、一個網頁瀏覽器130、一個雜湊模組134和一個網頁字型伺服器150。 首先,如步驟S110所示,網頁伺服器110被配置為在收到請求時向用戶的網頁瀏覽器130提供一個網頁和與該網頁相關的資源。這些資源可能包括各種元素,如HTML、CSS、JavaScript檔案、圖像和一個網頁字型腳本132。網頁伺服器110與用戶的網頁瀏覽器130進行通信,傳遞這些資源,使網頁瀏覽器130能夠為用戶渲染網頁。資源的傳遞通常通過標準協議如HTTP或HTTPS來實現。 接著,如步驟S132所示,網頁字型腳本132是從網頁伺服器110下載的特定資源。一旦下載,如步驟S130所示,它就在用戶的網頁瀏覽器130上運行,並確定網頁所需的字符集和字型資訊。字符集和字型資訊對於網頁的視覺呈現至關重要,它決定了要在網頁上顯示的特定字符及其風格表示。 此外,網頁瀏覽器130還與網頁字型伺服器150互動,發送字型子集152的請求並將收到的字型子集152應用於網頁。雜湊模組134是一個根據網頁字型腳本132確定的字符集和字型資訊生成雜湊值的元件。如步驟S134所示,雜湊模組134使用加密雜湊演算法,如MD5、SHA-2、或SHA-3,來生成與特定字符集和字型資訊組合唯一相關的雜湊值。這個雜湊值作為與字符集和字型資訊相對應的字型子集的獨特標識符。 網頁字型伺服器150被配置為接收基於雜湊模組134生成的雜湊值以請求字型子集。收到請求後,如步驟S150所示,網頁字型伺服器150檢查是否存在與請求的雜湊值相對應的字型子集152。如果這樣的字型子集152存在,則如步驟S136所示,網頁字型伺服器150將字型子集152返回給網頁瀏覽器130。如果沒有這樣的字型子集152存在,則如步驟S170所示,網頁字型伺服器150會根據網頁字型腳本130發送的字符集和字型資訊生成一個新的字型子集152。然後,新生成的字型子集152將與其對應的雜湊值一起存儲在網頁字型伺服器150上,以供未來使用。 以上,是對本發明之網頁字型加載優化方法與系統的簡介,以下將對所述方法與系統中所牽涉到的元件和步驟進行更詳細的介紹,請繼續參照圖1A與圖2。 在網頁伺服器110提供的資源中,網頁字型腳本132在優化網頁字型加載的過程中扮演著特定的角色。一旦從網頁伺服器110下載了網頁字型腳本132,它就在用戶的網頁瀏覽器130上運行。網頁字型腳本132的主要功能是確定網頁所需的字符集和字型資訊。這個識別過程涉及掃描網頁內容並確定要顯示的特定字符,以及由字型資訊決定的他們的風格表示。 網頁字型腳本132確定的字符集和字型資訊對於網頁的視覺呈現至關重要。字符集包括要在網頁上顯示的特定字符,如字母、數字、標點符號和特殊字符。另一方面,字型資訊決定了這些字符的風格表示,包括如字體、大小、權重和風格等方面。字符集和字型資訊共同決定了網頁文本的視覺外觀,對整體用戶體驗有所貢獻。 雜湊模組134是網頁字型加載優化系統100中的一個關鍵元件,負責根據網頁字型腳本132確定的字符集和字型資訊生成雜湊值。雜湊值作為一個獨特的標識符,與特定的字符集和字型資訊組合唯一相關。這個標識符在從網頁字型伺服器150請求和檢索相應的字型子集152的過程中起著關鍵的作用。 雜湊模組134使用加密雜湊演算法來生成雜湊值。加密雜湊演算法是數學演算法,它接受一個輸入並返回一個固定大小的字節串,亦即:雜湊值。這些演算法的特性是它們是確定的,意味著相同的輸入將始終產生相同的雜湊值。然而,輸入的微小變化可以導致雜湊值有顯著的不同,這是一種被稱為雪崩效應(Avalanche effect )的現象。這種特性在本案之網頁字型加載優化系統100的脈絡中是有利的,因為它確保了不同的字符集和字型資訊組合將產生不同的雜湊值,從而方便準確地檢索相應的字型子集152。 雜湊模組134可以使用的加密雜湊演算法包括MD5、SHA-2、以及SHA-3。MD5,即'Message Digest Algorithm 5',是一種廣泛使用的加密雜湊函數,它產生一個128位的雜湊值。它通常用於驗證資料完整性。另一方面,SHA-2是一組加密雜湊函數,包括SHA-224、SHA-256、SHA-384、SHA-512、SHA-512/224和SHA-512/256。名稱中的數字表示函數產生的雜湊值的長度。由於它們的雜湊值較長,SHA-2函數被認為比MD5更安全,使它們不易受到碰撞攻擊。另外,SHA-3是加密雜湊函數的最新系列,它提供了與SHA-2不同的設計,進一步增強了安全性和抗碰撞攻擊的能力。SHA-3在安全性上的提升使其成為處理高度敏感數據時的理想選擇。 在本網頁字型加載優化系統100的脈絡中,雜湊模組134將選定的加密雜湊演算法應用於網頁字型腳本132所確定的字符集和字型資訊。然後,生成的雜湊值被用作從網頁字型伺服器150請求相應的字型子集的標識符。基於字符集和字型資訊生成雜湊值並使用它來請求相應的字型子集152的過程是系統運作的核心部分,對於在網頁瀏覽器130中優化網頁字型加載有著重要的貢獻。 網頁字型伺服器150對於優化網頁字型加載的過程起著關鍵作用。網頁字型伺服器150被配置為根據雜湊模組134生成的雜湊值接收字型子集152的請求。這些請求由在用戶的網頁瀏覽器130上運行的網頁字型腳本132發送,該網頁字型腳本132根據為網頁確定的字符集和字型資訊生成一個雜湊值。 在收到請求後,網頁字型伺服器150檢查是否存在與請求的雜湊值相對應的字型子集152。這是通過將接收到的雜湊值與存儲在伺服器上的字型子集的雜湊值進行比較來實現的。如果找到了與雜湊值匹配的字型子集152,則表示在網頁字型伺服器150上已經存在一個與字符集和字型資訊匹配的字型子集。這可能是因為該字型子集已經為相同或不同的網頁先前加載過,或者是因為自上次加載以來網頁內容沒有變化。在這種情況下,網頁字型伺服器150將現有的字型子集152返回給網頁瀏覽器130。 如果網頁字型伺服器150沒有找到與雜湊值匹配的字型子集152,則表示在網頁字型伺服器150上不存在與字符集和字型資訊相對應的字型子集。這可能是因為該字型子集以前沒有被加載過,或者是因為自上次加載以來網頁內容已經變化,需要一個新的字型子集。在這種情況下,網頁字型伺服器150中的字型生成模組154會根據網頁字型腳本132發送的字符集和字型資訊生成一個新的字型子集152。在其中一實施例中,為了提升數據傳輸的效率,所使用的字符集是經過移除重複字符後的資料。 除了上一段所述方式外,還可以採用其他方式產生新的字型子集。請同時參照圖1B,在此實施例中,網頁字型伺服器150儲存有一常用字型檔案151。當網頁字型伺服器150接收到來自網頁瀏覽器130的字符集和字型資訊請求時,會首先判斷其常用字型檔案151中是否已經存在匹配的字型子集。如果存在,則會根據該請求進行以下操作: (a) 若所述常用字型檔案151完全涵蓋所需的字符集和字型資訊,網頁字型伺服器150將直接將該常用字型檔案151的URL發送到網頁瀏覽器130。這樣做可以有效減少字型加載時間並提升效率,因為沒有必要創建新的字型子集。 (b) 另一方面,如果所需的字符集和字型資訊只佔常用字型檔案所包含的一小部分,網頁字型伺服器150的字型抽取模組153會從該常用字型檔案151中抽取出所需的特定字符集和字型資訊,並根據這些資訊創建一個新的字型子集。這個新創建的字型子集將只包含網頁瀏覽器130所請求的特定字符和字型,從而提高加載效率並減少不必要的數據傳輸。 在上述兩種情況中,網頁字型伺服器150都將相應的URL發送到網頁瀏覽器130,以便將相應的字型子集應用於所請求的網頁。這種方法確保了只有必要的字型數據被加載,從而優化了整體網頁加載過程。在本實施例中,常用字型檔案151是網頁字型伺服器150中一個關鍵的元件,旨在儲存一組廣泛使用的字符和字型,這些字符和字型被認為是最常出現在多數網頁請求中。常用字型檔案151被設計為包含足夠多樣化的字符集,以滿足大多數網頁的基本需求。這樣,當網頁瀏覽器130請求特定字符集時,網頁字型伺服器150可以首先檢查常用字型檔案151,以確定是否已經有一個預先生成的、包含所需字符的字型子集。 由於常用字型檔案151的存在,網頁字型伺服器150在許多情況下能夠迅速回應字型請求,無需每次都生成新的字型子集。這種方式不僅節省了處理時間,還減少了網頁字型伺服器150的負荷,同時提高了網頁加載速度。常用字型檔案151的內容可以根據過去的使用數據和趨勢進行定期更新,以保證其始終反映最常見的網頁字型使用情況。 生成新的字型子集152的過程涉及根據字符集和字型資訊創建一個字型子集。字型子集152包括要在網頁上顯示的特定字符,並根據字型資訊進行風格設定。一旦生成了新的字型子集152,它就會與其對應的雜湊值一起存儲在網頁字型伺服器150上。存儲雜湊值使網頁字型伺服器150能夠快速且準確地為未來的請求檢索字型子集152。這個存儲過程是由映射模組156來負責,系統運作的核心部分,對於在網頁瀏覽器130中優化網頁字型加載有著重要的貢獻。映射模組156在記錄網頁字型伺服器150上的雜湊值和字型子集152之間的映射中扮演著關鍵的角色。這種映射對於未來請求的字型子集152的高效檢索至關重要。映射模組156是網頁字型伺服器150的一個元件,設計用來記錄由雜湊模組134生成的雜湊值和存儲在網頁字型伺服器150上的相應字型子集152之間的關聯。這種關聯,或映射,是雜湊值和字型子集152之間的一對一對應,這意味著每個雜湊值都與一個特定的字型子集152唯一相關,反之亦然。 此外,除了映射模組156在記錄雜湊值和字型子集152之間關係的作用外,網頁字型伺服器150還包括一個命名模組158,該命名模組158負責將每個字型子集152以其對應的雜湊值命名。這種命名方法不僅提高了檢索效率,還增加了字型子集的識別性。每個字型子集的名稱都是根據雜湊模組134生成的唯一雜湊值而定,這確保了名稱的唯一性和一致性。通過這種方式,當網頁瀏覽器130發出請求時,網頁字型伺服器150能夠快速地定位和提供正確的字型子集,從而進一步優化網頁字型的加載過程。在某些實施例中,命名模組158和映射模組156可以同時存在,而在某些實施例中,命名模組158和映射模組156則可以擇一存在。 通過採用這種過程,網頁字型伺服器150有效地管理字型子集152的存儲和檢索,優化了網頁瀏覽器130中的網頁字型加載。這個過程顯著減少了與網頁字型加載相關的計算開銷,特別是對於內容在多次訪問中保持不變的靜態網站。此外,通過存儲雜湊值以供未來使用,網頁字型伺服器150促進了字型子集152的快速和準確檢索,進一步提高了系統的效率。 以下,將介紹把字型子集152應用於網頁的過程,請同時參照圖3。這個過程涉及幾個步驟,每個步驟都對網頁文本的視覺呈現有所貢獻,而這個過程則是由網頁顯示程式136來實現(如圖4所示)。網頁顯示程式136也是由網頁字型伺服器150下載而來,包括URL插入模組162、下載模組164和渲染模組166,這些模組在將字型子集152應用於網頁的過程中都扮演著不同的角色。 首先,如步驟S210所示,URL插入模組162將字型子集152所對應的URL添加到網頁。URL,Uniform Resource Locator (全球資源定位器,通常稱為“網址”),在本實施例中是對儲存在網頁字型伺服器150上的字型子集152的引用,它提供了字型子集152在網頁字型伺服器150上的位置和檢索它的協議。字型子集152所對應的URL由在用戶的網頁瀏覽器130上運行的網頁字型腳本添加到網頁,這通常是通過將URL插入到網頁的HTML或CSS中來進行。 一旦將字型子集152所對應的URL添加到網頁,下一步就是下載模組164根據URL下載字型子集152(如步驟S220所示)。這是下載模組164使用URL向網頁字型伺服器150發送請求,促使網頁字型伺服器150將字型子集152通過網路傳輸。網頁字型伺服器150對請求作出回應,將字型子集152發送到網頁瀏覽器130。該檔案通過網路傳輸並由網頁瀏覽器130接收,該網頁瀏覽器130將其存儲在本地,以便在渲染網頁文本時使用。 再來,如步驟S230所示,在網頁瀏覽器130中渲染字型子集,這可以由渲染模組166來執行。字型子集包含在網頁上要顯示的特定字符,並根據字型資訊進行風格設定。網頁瀏覽器130中的渲染模組166使用這個字型子集來渲染網頁文本,將默認或先前應用的字型替換為字型子集指定的字型。這個渲染過程由渲染模組166與網頁瀏覽器130的渲染引擎一起工作,該渲染引擎解釋網頁的HTML、CSS和其他資源,包括字型子集150,以生成網頁的視覺呈現。 通過這些步驟,網頁字型伺服器150返回的字型子集被應用於網頁,對網頁文本的視覺呈現有所貢獻。這個過程是系統運作的一個整體部分,使網頁瀏覽器130能夠有效地加載網頁字型,並提高了整體用戶體驗。 網頁字型加載優化系統100具有幾個潛在的優點,特別是在計算效率和網頁加載速度方面。一個主要的優點是減少了與網頁字型加載相關的計算開銷。通過採用基於雜湊的方法來請求和檢索字型子集,系統消除了特別是對於內容在多次訪問中保持不變的靜態網站的冗餘字型子集生成。這顯著減少了網頁字型伺服器150消耗的計算資源,從而提高了網頁字型加載優化系統100的整體效率。 網頁字型加載優化系統100的另一個顯著優點是提高網頁加載速度。通過在網頁字型伺服器150上存儲雜湊值和相應的字型子集,系統100便於根據雜湊值快速且準確地檢索字型子集152。這消除了每次加載網頁時在網頁字型伺服器150上搜索字型子集152的耗時過程,從而減少了網頁加載時間。這種加載速度的提高對用戶體驗特別有利,因為它減少了用戶的等待時間,並使他們能夠更快地與網頁互動。 此外,網頁字型加載優化系統100在處理網頁字型加載的效率對於靜態網站特別有利,其中的內容在多次訪問中保持不變。在這種情況下,系統可以根據雜湊值檢索先前加載的字型子集152,消除了每次加載網頁時生成新字型子集的不必要性。這不僅減少了網頁字型伺服器的計算開銷,而且提高了網頁加載速度,從而提升了整體的用戶體驗。 值得注意的是,這些優點可能存在於系統的一個或多個實施例中。實現的具體好處可能取決於各種因素,如系統的具體配置、網頁的特性和字型子集的性質。無論如何,系統優化網頁字型加載的方法提供了一種有前景的解決方案,以應對傳統網頁字型加載技術的挑戰,提供了在計算效率、網頁加載速度和用戶體驗方面的潛在改進。 雖然本發明已以較佳實施例揭露如上,然其並非用以限定本發明,任何所屬技術領域中具有通常知識者,在不脫離本發明之精神和範圍內,當可作些許之更動與潤飾,因此本發明之保護範圍當視後附之申請專利範圍所界定者為準。 The present invention is best understood with reference to the detailed contents and accompanying drawings set forth herein. Various embodiments will be discussed below with reference to the accompanying drawings. However, it will be readily understood by those skilled in the art that the detailed description given here with respect to the accompanying drawings is for illustrative purposes only, as these methods and systems may extend beyond the described embodiments. For example, the given teachings and the requirements of a particular application may result in a variety of optional and suitable methods to implement the functionality of any detail described herein. Therefore, any method may extend beyond the specific implementation options described and shown in the following embodiments. Please refer to Figures 1A and 2, Figure 1A is a block diagram of one embodiment of the web page font loading optimization system of the present invention, and Figure 2 is a flow chart of the web page font loading optimization method of the present invention. The web font loading optimization system 100 includes multiple components, each of which plays a different role in the process. The web font loading optimization 100 includes a web server 110, a web font script 132, a web browser 130, a hash module 134 and a web font server 150. First, as shown in step S110, the web server 110 is configured to provide a web page and resources related to the web page to the user's web browser 130 when a request is received. These resources may include various elements, such as HTML, CSS, JavaScript files, images and a web font script 132. The web server 110 communicates with the user's web browser 130 to deliver these resources so that the web browser 130 can render the web page for the user. The delivery of resources is usually achieved through standard protocols such as HTTP or HTTPS. Next, as shown in step S132, the web font script 132 is a specific resource downloaded from the web server 110. Once downloaded, as shown in step S130, it runs on the user's web browser 130 and determines the character set and font information required for the web page. The character set and font information are crucial to the visual presentation of the web page, which determines the specific characters and their style representation to be displayed on the web page. In addition, the web browser 130 also interacts with the web font server 150, sends a request for a font subset 152 and applies the received font subset 152 to the web page. The hash module 134 is a component that generates a hash value based on the character set and font information determined by the web font script 132. As shown in step S134, the hash module 134 uses a cryptographic hash algorithm, such as MD5, SHA-2, or SHA-3, to generate a hash value uniquely associated with a specific character set and font information combination. This hash value serves as a unique identifier for the font subset corresponding to the character set and font information. The web font server 150 is configured to receive a request for a font subset based on a hash value generated by the hash module 134. After receiving the request, as shown in step S150, the web font server 150 checks whether there is a font subset 152 corresponding to the requested hash value. If such a font subset 152 exists, as shown in step S136, the web font server 150 returns the font subset 152 to the web browser 130. If no such font subset 152 exists, as shown in step S170, the web font server 150 generates a new font subset 152 according to the character set and font information sent by the web font script 130. Then, the newly generated font subset 152 will be stored together with its corresponding hash value on the web font server 150 for future use. The above is an introduction to the web font loading optimization method and system of the present invention. The following will introduce the elements and steps involved in the method and system in more detail. Please continue to refer to Figures 1A and 2. Among the resources provided by the web server 110, the web font script 132 plays a specific role in the process of optimizing web font loading. Once the web font script 132 is downloaded from the web server 110, it runs on the user's web browser 130. The main function of the web font script 132 is to determine the character set and font information required for the web page. This recognition process involves scanning the web page content and determining the specific characters to be displayed, as well as their stylistic representation as determined by the font information. The character set and font information determined by the web page font script 132 are crucial to the visual presentation of the web page. The character set includes the specific characters to be displayed on the web page, such as letters, numbers, punctuation marks, and special characters. On the other hand, the font information determines the stylistic representation of these characters, including aspects such as font, size, weight, and style. Together, the character set and font information determine the visual appearance of the web page text and contribute to the overall user experience. The hash module 134 is a key component in the web font loading optimization system 100, responsible for generating a hash value based on the character set and font information determined by the web font script 132. The hash value is a unique identifier that is uniquely associated with a specific combination of character set and font information. This identifier plays a key role in the process of requesting and retrieving the corresponding font subset 152 from the web font server 150. The hash module 134 uses a cryptographic hash algorithm to generate a hash value. A cryptographic hash algorithm is a mathematical algorithm that accepts an input and returns a fixed-size byte string, that is, a hash value. The property of these algorithms is that they are deterministic, meaning that the same input will always produce the same hash value. However, small changes in the input can result in significantly different hash values, a phenomenon known as the avalanche effect. This property is advantageous in the context of the web font loading optimization system 100 of the present case because it ensures that different character set and font information combinations will produce different hash values, thereby facilitating accurate retrieval of the corresponding font subset 152. The cryptographic hashing algorithms that can be used by the hash module 134 include MD5, SHA-2, and SHA-3. MD5, or 'Message Digest Algorithm 5', is a widely used cryptographic hash function that produces a 128-bit hash value. It is often used to verify data integrity. On the other hand, SHA-2 is a family of cryptographic hash functions that includes SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256. The number in the name indicates the length of the hash value produced by the function. Due to their longer hash values, SHA-2 functions are considered more secure than MD5, making them less vulnerable to collision attacks. In addition, SHA-3 is the latest family of cryptographic hash functions that offers a different design from SHA-2, further enhancing security and resistance to collision attacks. The increased security provided by SHA-3 makes it an ideal choice when handling highly sensitive data. In the context of the present web font loading optimization system 100, the hash module 134 applies a selected cryptographic hashing algorithm to the character set and font information determined by the web font script 132. The generated hash value is then used as an identifier to request the corresponding font subset from the web font server 150. The process of generating a hash value based on the character set and font information and using it to request the corresponding font subset 152 is a core part of the system's operation and is an important contribution to optimizing web font loading in the web browser 130. The web font server 150 plays a key role in the process of optimizing web font loading. The web font server 150 is configured to receive requests for font subsets 152 based on hash values generated by the hash module 134. These requests are sent by the web font script 132 running on the user's web browser 130, which generates a hash value based on the character set and font information determined for the web page. After receiving the request, the web font server 150 checks whether there is a font subset 152 corresponding to the requested hash value. This is achieved by comparing the received hash value with the hash values of the font subsets stored on the server. If a font subset 152 matching the hash value is found, then a font subset matching the character set and font information already exists on the web font server 150. This may be because the font subset has been previously loaded for the same or a different web page, or because the web page content has not changed since the last load. In this case, the web font server 150 returns the existing font subset 152 to the web browser 130. If the web font server 150 does not find a font subset 152 matching the hash value, then a font subset corresponding to the character set and font information does not exist on the web font server 150. This may be because the font subset has not been previously loaded, or because the web page content has changed since the last load and a new font subset is needed. In this case, the font generation module 154 in the web font server 150 generates a new font subset 152 according to the character set and font information sent by the web font script 132. In one embodiment, in order to improve the efficiency of data transmission, the character set used is the data after removing duplicate characters. In addition to the method described in the previous paragraph, other methods can also be used to generate new font subsets. Please refer to Figure 1B at the same time. In this embodiment, the web font server 150 stores a common font file 151. When the web font server 150 receives a character set and font information request from the web browser 130, it will first determine whether a matching font subset already exists in its common font file 151. If it exists, the following operations will be performed according to the request: (a) If the common font file 151 completely covers the required character set and font information, the web font server 150 will directly send the URL of the common font file 151 to the web browser 130. This can effectively reduce the font loading time and improve efficiency because there is no need to create a new font subset. (b) On the other hand, if the required character set and font information only account for a small part of the common font file, the font extraction module 153 of the web font server 150 will extract the required specific character set and font information from the common font file 151 and create a new font subset based on this information. This newly created font subset will only contain the specific characters and fonts requested by the web browser 130, thereby improving loading efficiency and reducing unnecessary data transmission. In both of the above cases, the web font server 150 sends the corresponding URL to the web browser 130 so that the corresponding font subset can be applied to the requested web page. This approach ensures that only the necessary font data is loaded, thereby optimizing the overall web page loading process. In this embodiment, the common font file 151 is a key element in the web font server 150, which is intended to store a set of widely used characters and fonts that are believed to appear most frequently in most web page requests. The common font file 151 is designed to contain a sufficiently diverse character set to meet the basic needs of most web pages. Thus, when a web browser 130 requests a specific character set, the web font server 150 can first check the common font file 151 to determine whether there is already a pre-generated font subset containing the required characters. Due to the existence of the common font file 151, the web font server 150 can respond to font requests quickly in many cases without having to generate a new font subset each time. This approach not only saves processing time, but also reduces the load on the web font server 150, while increasing the web page loading speed. The content of the common font file 151 can be regularly updated based on past usage data and trends to ensure that it always reflects the most common web font usage. The process of generating a new font subset 152 involves creating a font subset based on the character set and font information. The font subset 152 includes specific characters to be displayed on the web page and is styled according to the font information. Once the new font subset 152 is generated, it is stored on the web font server 150 along with its corresponding hash value. Storing the hash value enables the web font server 150 to quickly and accurately retrieve the font subset 152 for future requests. This storage process is handled by the mapping module 156, which is a core part of the system operation and plays an important role in optimizing web font loading in the web browser 130. The mapping module 156 plays a key role in recording the mapping between hash values and font subsets 152 on the web font server 150. This mapping is essential for efficient retrieval of font subsets 152 for future requests. The mapping module 156 is a component of the web font server 150 designed to record the association between the hash values generated by the hash module 134 and the corresponding font subsets 152 stored on the web font server 150. This association, or mapping, is a one-to-one correspondence between hash values and font subsets 152, which means that each hash value is uniquely associated with a specific font subset 152 and vice versa. In addition to the role of the mapping module 156 in recording the relationship between the hash value and the font subset 152, the web font server 150 also includes a naming module 158, which is responsible for naming each font subset 152 according to its corresponding hash value. This naming method not only improves the retrieval efficiency, but also increases the identification of the font subset. The name of each font subset is determined according to the unique hash value generated by the hash module 134, which ensures the uniqueness and consistency of the name. In this way, when the web browser 130 issues a request, the web font server 150 can quickly locate and provide the correct font subset, thereby further optimizing the web font loading process. In some embodiments, the naming module 158 and the mapping module 156 may exist simultaneously, while in some embodiments, the naming module 158 and the mapping module 156 may exist selectively. By adopting this process, the web font server 150 effectively manages the storage and retrieval of the font subset 152, optimizing the web font loading in the web browser 130. This process significantly reduces the computational overhead associated with web font loading, especially for static websites whose content remains unchanged over multiple visits. In addition, by storing hash values for future use, the web font server 150 facilitates fast and accurate retrieval of the font subset 152, further improving the efficiency of the system. The following will introduce the process of applying the font subset 152 to a web page, please refer to FIG3. This process involves several steps, each of which contributes to the visual presentation of the web page text, and this process is implemented by the web page display program 136 (as shown in FIG4). The web page display program 136 is also downloaded from the web font server 150, including a URL insertion module 162, a download module 164 and a rendering module 166, which play different roles in the process of applying the font subset 152 to a web page. First, as shown in step S210, the URL insertion module 162 adds the URL corresponding to the font subset 152 to the web page. URL, Uniform Resource Locator (Global Resource Locator, commonly referred to as "URL"), in this embodiment is a reference to a font subset 152 stored on a web font server 150, which provides the location of the font subset 152 on the web font server 150 and a protocol for retrieving it. The URL corresponding to the font subset 152 is added to the web page by a web font script running on the user's web browser 130, which is usually done by inserting the URL into the HTML or CSS of the web page. Once the URL corresponding to the font subset 152 is added to the web page, the next step is for the download module 164 to download the font subset 152 according to the URL (as shown in step S220). This is the download module 164 sending a request to the web font server 150 using the URL, prompting the web font server 150 to transmit the font subset 152 through the network. The web font server 150 responds to the request and sends the font subset 152 to the web browser 130. The file is transmitted through the network and received by the web browser 130, which stores it locally for use when rendering web page text. Next, as shown in step S230, the font subset is rendered in the web browser 130, which can be executed by the rendering module 166. The font subset contains specific characters to be displayed on the web page and is styled according to the font information. The rendering module 166 in the web browser 130 uses this font subset to render the web page text, replacing the default or previously applied font with the font specified by the font subset. This rendering process is performed by the rendering module 166 working with the rendering engine of the web browser 130, which interprets the HTML, CSS and other resources of the web page, including the font subset 150, to generate the visual presentation of the web page. Through these steps, the font subset returned by the web font server 150 is applied to the web page and contributes to the visual presentation of the web page text. This process is an integral part of the operation of the system, enabling the web browser 130 to load web fonts efficiently and improve the overall user experience. The web font loading optimization system 100 has several potential advantages, particularly in terms of computational efficiency and web page loading speed. One major advantage is the reduction of computational overhead associated with web page font loading. By employing a hash-based approach to requesting and retrieving font subsets, the system eliminates redundant font subset generation, particularly for static websites whose content remains unchanged across multiple visits. This significantly reduces the computing resources consumed by the web font server 150, thereby improving the overall efficiency of the web font loading optimization system 100. Another significant advantage of the web font loading optimization system 100 is improved web page loading speed. By storing hash values and corresponding font subsets on the web font server 150, the system 100 facilitates fast and accurate retrieval of the font subset 152 based on the hash value. This eliminates the time-consuming process of searching the font subset 152 on the web font server 150 each time a web page is loaded, thereby reducing web page loading time. This increase in loading speed is particularly beneficial to the user experience because it reduces the user's waiting time and enables them to interact with the web page more quickly. In addition, the efficiency of the web font loading optimization system 100 in handling web font loading is particularly beneficial for static websites, where the content remains unchanged across multiple visits. In this case, the system can retrieve the previously loaded font subset 152 based on the hash value, eliminating the need to generate a new font subset each time a web page is loaded. This not only reduces the computing overhead of the web font server, but also increases the web page loading speed, thereby improving the overall user experience. It is worth noting that these advantages may exist in one or more embodiments of the system. The specific benefits achieved may depend on various factors, such as the specific configuration of the system, the characteristics of the web page, and the nature of the font subset. In any case, the method of systematically optimizing web page font loading provides a promising solution to the challenges of traditional web page font loading technology, providing potential improvements in computing efficiency, web page loading speed, and user experience. Although the present invention has been disclosed as above with preferred embodiments, it is not intended to limit the present invention. Any person with ordinary knowledge in the relevant technical field may make slight changes and modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be defined by the scope of the attached patent application.
100:網頁字型加載優化系統 110:網頁伺服器 132:網頁字型腳本 130:網頁瀏覽器 134:雜湊模組 136:網頁顯示程式 150:網頁字型伺服器 151:常用字型檔案 152:字型子集 153:字型抽取模組 154:字型生成模組 156:映射模組 158:命名模組 162:URL插入模組 164:下載模組 166:渲染模組 S110~S170:流程圖步驟 S210~S230:流程圖步驟 100: Web font loading optimization system 110: Web server 132: Web font script 130: Web browser 134: Hash module 136: Web display program 150: Web font server 151: Common font files 152: Font subset 153: Font extraction module 154: Font generation module 156: Mapping module 158: Naming module 162: URL insertion module 164: Download module 166: Rendering module S110~S170: Flowchart steps S210~S230: Flowchart steps
下文將根據附圖來描述各種實施例,所述附圖是用來說明而不是用以任何方式來限制範圍,其中相似的標號表示相似的組件,並且其中: 圖1A所繪示為本發明之網頁字型加載優化系統之其中一實施例的方塊圖。 圖1B所繪示為本發明之網頁字型加載優化系統之另外一實施例的方塊圖。 圖2所繪示為本發明之網頁字型加載優化方法之流程圖。 圖3所繪示為本發明之將字型子集應用於網頁的過程之流程圖。 圖4所繪示為本發明之網頁顯示程式的方塊圖。 Various embodiments will be described below based on the accompanying drawings, which are used for illustration and not to limit the scope in any way, wherein like numbers represent like components, and wherein: FIG. 1A shows a block diagram of one embodiment of the web page font loading optimization system of the present invention. FIG. 1B shows a block diagram of another embodiment of the web page font loading optimization system of the present invention. FIG. 2 shows a flow chart of the web page font loading optimization method of the present invention. FIG. 3 shows a flow chart of the process of applying a font subset to a web page of the present invention. FIG. 4 shows a block diagram of the web page display program of the present invention.
S110~S170:流程圖步驟 S110~S170: Flowchart steps
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW112148361A TWI904517B (en) | 2023-12-12 | Web font loading optimization method and system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW112148361A TWI904517B (en) | 2023-12-12 | Web font loading optimization method and system |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| TW202524335A true TW202524335A (en) | 2025-06-16 |
| TWI904517B TWI904517B (en) | 2025-11-11 |
Family
ID=
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8560841B2 (en) | Request authentication token | |
| EP2537090B1 (en) | Preventing unauthorized font linking | |
| US9077681B2 (en) | Page loading optimization using page-maintained cache | |
| JP5420087B2 (en) | Method and system for providing a message including a universal resource locator | |
| US8078726B2 (en) | System and method for cacheing web files | |
| CN100462964C (en) | A method for updating and displaying web page data | |
| US20120036264A1 (en) | Efficient Storage and Retrieval of Resources for Rendering Structured Documents | |
| US10645192B2 (en) | Identifying content files in a cache using a response-based cache index | |
| WO2014120908A1 (en) | Accessing objects in hosted storage | |
| US9473592B2 (en) | Methods for optimizing a web content proxy server and devices thereof | |
| CN106210161A (en) | A kind of short chain delivers a child into method and system | |
| US20250373586A1 (en) | System and method to anonymize data transmitted to a destination computing device | |
| CN109634916A (en) | File storage and method for down loading, device and storage medium | |
| CN105677646A (en) | Word stock generation method and system, and server | |
| US8352442B2 (en) | Determination of an updated data source from disparate data sources | |
| CN114282233A (en) | WEB performance optimization method and device, computer equipment and storage medium | |
| EP1907922A1 (en) | A method for detecting state changes between data stored in a first computing device and data received from a second computing device | |
| EP2380098A1 (en) | Dictionary-based data compression and subsequent data transmission in a server / client architecture | |
| TWI904517B (en) | Web font loading optimization method and system | |
| US11580246B2 (en) | Cryptographic data encoding method with enhanced data security | |
| TW202524335A (en) | Web font loading optimization method and system | |
| CN116089751B (en) | Method and device for rendering server, readable storage medium and electronic equipment | |
| CN113364848B (en) | File caching method and device, electronic equipment and storage medium | |
| US8862694B2 (en) | If-none-match for aggregated page distribution | |
| CN114491480A (en) | A web page anti-counterfeiting verification method, device, terminal device and storage medium |