Method for improving website access loading efficiency

By modularizing the first-screen CSS and using JavaScript Worker child threads to load resources asynchronously, the problems of too long loading time on the first-screen and blocking of the main thread caused by traditional web page loading methods are solved, and faster page loading speed and better user experience are achieved.

CN119961535APending Publication Date: 2025-05-09NANJING FOCUS LINGDONG CLOUD COMPUTING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510041467.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-10
Publication Date
2025-05-09

AI Technical Summary

Technical Problem

Traditional web page loading methods lead to too long loading time on the first screen, blocking the main thread, affecting the user experience, and especially on mobile devices, resource waste is serious.

Method used

By modularizing the first-screen CSS and using JavaScript Worker child threads to load CSS below the first-screen and all JS resources asynchronously, avoid blocking the main thread and optimize resource loading strategies.

Benefits of technology

It significantly improves page loading speed and user experience, ensures the fast presentation of the first screen content, reduces resource waste, and improves page response speed and overall performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119961535A_ABST
    Figure CN119961535A_ABST
Patent Text Reader

Abstract

The invention discloses a method for improving website access loading efficiency. Carrying out headt; a first-screen CSS is divided according to modules in a label, and a JavaScript Worker sub-thread is utilized to process CSSs below the first screen and all JS resources, namely 1) the first-screen CSS is divided according to the modules; (2) the CSS files below the first screen pass through a JS Worker sub-thread, and the sub-thread is used for asynchronously loading the CSS files below the first screen; creating a Worker script which is responsible for loading and analyzing the CSS files and returning an analysis result to the main thread; after receiving the analysis result, the main thread inserts the analysis result into a document to ensure that contents below a first screen can be correctly displayed as required; (3) all the JS resources pass through the sub-threads, and loading and execution tasks of all the JS resources are distributed to the sub-threads; and creating a Worker script which is responsible for loading and executing the JS files and calling and transmitting necessary data and events back to a main thread.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer data processing, and in particular relates to a solution for quickly completing loading of a page in a browser. Background Art

[0002] With the rapid development of Internet applications, users have higher and higher requirements for website loading speed. Traditional web page loading methods often lead to long first screen loading time, affecting user experience. Especially on mobile devices, where network conditions are unstable, the loading speed problem is more prominent. Therefore, how to optimize web page loading efficiency has become an important research direction.

[0003] CSS styles can be stored directly in HTML web pages or in separate style sheet files. In either case, the style sheet contains rules for applying styles to elements of a specified type. The traditional loading method usually loads all CSS and JS resources at once when the page loads, which will result in a long first screen loading time, especially when there are many resources. In addition, the synchronous loading and execution of JavaScript will block the main thread, further affecting the page's responsiveness and user experience. Therefore, optimizing the loading strategy of CSS and JS, especially taking advantage of the multi-threading capabilities of modern browsers, has become the key to improving web page loading efficiency.

[0004] In traditional web development, all CSS and JavaScript files are usually loaded synchronously when the page loads, which leads to the following problems:

[0005] (1) Long first screen loading time: All resources need to be loaded when the page loads, which increases the rendering time of the first screen content and reduces the user experience.

[0006] (2) Main thread blocking: The synchronous loading and execution of JavaScript will block the main thread, causing the page to be unable to respond to user operations in a timely manner, affecting the user experience.

[0007] (3) Resource waste: If the user only browses part of the page, loading all the resources of the entire page will lead to resource waste, especially on mobile devices where bandwidth and traffic are limited.

[0008] In order to deal with these problems, a variety of optimization technologies have been introduced in modern web page development, such as resource segmentation, lazy loading, asynchronous loading, etc. These technologies can significantly improve the loading speed and user experience of web pages. The present invention proposes a method for processing non-first-screen resources by modularizing the first-screen CSS and using JavaScript Worker sub-threads, aiming to further optimize the loading efficiency of web pages. Summary of the invention

[0009] The purpose of the present invention is to propose a method for improving the loading efficiency of website access, and use JavaScriptWorker sub-threads to process CSS and all JS resources below the first screen, thereby significantly improving page loading speed and user experience.

[0010] The first screen CSS is divided into modules

[0011] (1) In the tag, divide the CSS required for the first screen into modules, and place the CSS of each module in the corresponding <style>标签中。

[0012] (2)如果首屏包含导航栏、轮播图和主要内容区域,分别在<head>中添加三个<style>标签,每个标签包含对应模块的CSS。

[0013] 首屏以下CSS走JS Worker子线程

[0014] (3)使用JavaScript Worker子线程(JavaScript Worker可实现多线程)异步加载首屏以下的CSS文件。

[0015] (4)创建一个Worker脚本,负责加载和解析这些CSS文件,并将解析结果返回给主线程。

[0016] (5)主线程接收到解析结果后,将其插入到文档中,确保首屏以下的内容在需要时能够正确显示。

[0017] 所有JS资源走子线程

[0018] 将所有JS资源的加载和执行任务分配给JavaScript Worker子线程。

[0019] (7)创建一个Worker脚本,负责加载和执行这些JS文件,并将必要的数据和事件回调传递回主线程。通过这种方式,避免了JS资源阻塞主线程,提高了页面的响应速度和用户体验。

[0020] 为了提升网站的访问加载效率,提出了一种创新方案:通过模块化首屏CSS的精细划分和JavaScript Worker子线程处理非首屏资源。首先,将首屏所需的CSS细分为多个功能模块(如导航栏、页头、页脚等),每个模块的CSS独立加载,减少不必要的样式加载,进一步提升首屏渲染速度。

[0021] 同时,根据用户的浏览行为或页面内容动态调整各个模块CSS的加载优先级,确保用户最关注的内容优先加载。例如,当用户进入页面时,系统会根据用户的浏览行为(如点击、滚动等)或页面内容(如首屏的导航栏、轮播图等)动态调整CSS的加载顺序。如果用户快速滚动页面,系统会优先加载即将进入视口的模块的CSS,确保用户浏览的流畅性。

[0022] 此外,通过JavaScript Worker子线程异步加载首屏以下的CSS和所有JS资源,避免阻塞主线程,确保首屏内容快速呈现。利用Worker线程提前预取后续页面可能用到的资源,并结合浏览器缓存机制,减少重复加载,提升整体性能。此外,通过JavaScript Worker子线程异步加载首屏以下的CSS和所有JS资源,避免阻塞主线程,确保首屏内容快速呈现。利用Worker线程提前预取后续页面可能用到的资源,并结合浏览器缓存机制,减少重复加载,提升整体性能。

[0023] 在资源管理方面,采用懒加载技术对非首屏的图片、视频等大文件进行按需加载,减少初始加载时间;我们将首屏的关键CSS内联到HTML文档中,确保搜索引擎爬虫能够快速获取页面结构,提升SEO效果;并在HTML中合理使用ARIA属性和语义化标签,增强页面的可访问性。

[0024] 本发明创新点如下:

[0025] 1、使用JavaScript Worker子线程异步加载首屏以下的CSS文件,避免阻塞首屏渲染,提升用户体验

[0026] 2、根据用户行为或页面内容动态调整各模块CSS的加载优先级,确保关键内容优先加载。

[0027] 3、利用Worker线程提前预取后续页面资源,并结合浏览器缓存机制,减少重复加载,提升整体性能。

[0028] 4、将首屏的关键CSS内联到HTML中,确保搜索引擎快速获取页面结构,提升SEO效果。

[0029] 5、对非首屏的图片、视频等大文件采用懒加载技术,减少初始加载时间。

[0030] 6、将所有JS资源的加载和执行任务分配给Worker子线程,避免阻塞主线程,提高页面响应速度。

[0031] 7、创建Worker脚本负责加载和执行JS文件,并将必要数据和事件回调传递回主线程,确保交互逻辑即时可用。

[0032] 8、根据网络状况和用户行为动态调整资源加载策略,确保在各种环境下获得最佳加载速度和用户体验。

[0033] 有益效果:与现有技术相比,其显著优点以及形成的效果有:

[0034] (1)通过按模块划分首屏CSS,确保首屏内容能够快速加载和显示,减少用户的等待时间。

[0035] (2)首屏以下的CSS和所有JS资源通过子线程异步加载,不会阻塞首屏内容的渲染。

[0036] (3)优先加载和解析首屏所需的资源,确保用户能够尽快看到主要内容。

[0037] (4)首屏以下的资源在后台异步加载,不影响用户的交互体验。

[0038] (5)通过将JS资源的加载和执行任务分配给子线程,避免了主线程被长时间阻塞,提高了页面的响应速度。

[0039] (6)快速的首屏加载和流畅的页面响应,显著提升了用户的整体体验。附图说明

[0040] 通过结合附图对本发明的实施例进行详细描述,本发明的上述和其它目的、特征、优点将会变得更加清楚,其中:

[0041] 图1为提升网站访问加载效率的方法结构示意图具体实施方式

[0042] 为了本领域普通技术人员理解和实施本发明,下面结合附图及实施例对本发明作进一步的详细描述,应当理解,此处所描述的实施示例仅用于说明和解释本发明,并不用于限定本发明。

[0043] 本发明旨在提供一种优化网页加载速度和用户体验的方法,具体通过将首屏所需的CSS和JS资源进行合理划分和异步加载来实现。这些步骤和方法可以根据具体项目需求进行调整和优化,以达到最佳的性能效果。

[0044] 实施示例中的具体技术细节和实现方式仅供参考,实际应用中可以根据实际情况进行适当的修改和扩展。

[0045] 图1为本发明实施例中具体实现方法系统结构示意图。

[0046] 具体步骤如下:

[0047] 步骤一:在网页的头部标签<head>中,将首屏所需的CSS按功能模块进行划分。每个模块的CSS放在对应的<style>标签中,确保首屏加载时只包含必要的样式,减少渲染阻塞。

[0048] 步骤二:如果首屏包含导航栏、轮播图和主要内容区域,分别在<head>中添加三个独立的<style>标签,每个标签仅包含对应模块的CSS。这样可以进一步优化首屏加载速度,并确保各部分样式独立加载,提高页面响应性。

[0049] 步骤三:使用JavaScript Worker子线程异步加载首屏以下的CSS文件。通过这种方式,避免这些非首屏CSS文件的加载阻塞首屏内容的渲染,提升用户体验。

[0050] 步骤四:创建一个专门的Worker脚本,负责加载和解析这些非首屏CSS文件,并将解析结果返回给主线程。提高加载效率,减少主线程的压力,使页面更加流畅。

[0051] 步骤五:当Worker脚本完成解析后,主线程接收到解析结果并将其插入到文档中。可以确保首屏以下的内容在需要时能够正确显示,同时不影响首屏的快速加载。

[0052] 步骤六:将所有JS资源的加载和执行任务分配给JavaScript Worker子线程。通过这种方式,避免JS资源阻塞主线程,提高页面的响应速度和整体性能。

[0053] 步骤七:创建一个Worker脚本,负责加载和执行这些JS文件,并将必要的数据和事件回调传递回主线程。提升了加载效率,确保关键交互逻辑在用户需要时立即可用,不影响页面的初始渲染。

[0054] 步骤八:采用懒加载技术对非首屏的图片、视频等大文件进行按需加载,减少初始加载时间。

[0055] 以上所述仅是本发明的优选实施方式,应当指出:对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。< / style>

Claims

1. A method for improving website access loading efficiency, characterized in that: By dividing the first screen CSS into modules in the tag and using JavaScript Worker sub-threads to process the CSS and all JS resources below the first screen, 1) The first screen CSS is divided into modules (1) In the tag, divide the CSS required for the first screen into modules, and place the CSS of each module in the corresponding <style>标签中;(2)如果首屏包含导航栏、轮播图和主要内容区域,分别在<head>中添加三个<style>标签,每个标签包含对应模块的CSS;2)首屏以下CSS走JS Worker子线程(3)使用JavaScript Worker子线程(JavaScript Worker可实现多线程)异步加载首屏以下的CSS文件;(4)创建一个Worker脚本,负责加载和解析这些CSS文件,并将解析结果返回给主线程;(5)主线程接收到解析结果后,将其插入到文档中,确保首屏以下的内容在需要时能够正确显示;3)所有JS资源走子线程(6)将所有JS资源的加载和执行任务分配给JavaScript Worker子线程;(7)创建一个Worker脚本,负责加载和执行这些JS文件,并将必要的数据和事件回调传递回主线程;通过这种方式,避免了JS资源阻塞主线程,提高了页面的响应速度和用户体验。2.根据权利要求1所述的提升网站访问加载效率的方法,其特征是,优先加载和解析首屏所需的资源。< / style>