A style storage method, device, equipment and storage medium
Patent Information
- Application Number
- CN202511298092.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-11
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2045-09-11
AI Technical Summary
[0004]有鉴于此,本申请提供了一种样式存储方法、装置、设备和存储介质,用于解决现有的样式存储方法不能实现高效的存储,还是会造成样式数据冗余,从而导致加载性能大幅度降低,严重影响页面的正常使用的问题
[0052] As can be seen from the above technical solution, this application obtains Cascading Style Sheet (CSS) rules, decomposes these rules into atomic style blocks, combines and optimizes these atomic style blocks to form target style blocks, generates hash codes corresponding to each target style block, constructs a style-code index table based on the hash codes of each target style block, and stores each target style block using the style-code index table. This application first obtains CSS rules and then decomposes them into atomic style blocks, ensuring the accuracy and efficiency of subsequent storage. The combination and optimization of the atomic style blocks reduces the storage size required for each block without affecting storage accuracy. Simultaneously, generating corresponding hash codes allows for direct storage, significantly reducing memory requirements. To ensure correspondence, a style-code index table is constructed for each hash code, and finally, the style-code index table is used for storage. This approach achieves efficient storage optimization, avoids style data redundancy, improves loading performance, and ensures normal page usage.
Smart Images

Figure CN121144561B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of pattern storage technology, specifically to a pattern storage method, apparatus, device, and storage medium. Background Technology
[0002] With the rapid development of web front-end technologies, large-scale single-page applications (SPAs) and complex enterprise-level web projects are becoming increasingly common. In these projects, the size and complexity of Cascading Style Sheets (CSS) are growing exponentially. How to efficiently and maintainably manage and store style code has become a key challenge affecting front-end development efficiency and application performance.
[0003] However, existing style storage methods cannot achieve efficient storage and still cause style data redundancy, which leads to a significant reduction in loading performance and seriously affects the normal use of the page. Summary of the Invention
[0004] In view of this, this application provides a style storage method, apparatus, device, and storage medium to solve the problem that existing style storage methods cannot achieve efficient storage and still cause style data redundancy, resulting in a significant reduction in loading performance and seriously affecting the normal use of the page.
[0005] To achieve the above objectives, the following solution is proposed:
[0006] Firstly, a style storage method includes:
[0007] Obtain the Cascading Style Sheet (CSS) rules and break them down into individual atomic style blocks;
[0008] The atomic-level style blocks are combined and optimized to form the target style blocks.
[0009] Generate hash codes corresponding to each of the target style blocks;
[0010] Based on the hash code of each target style block, construct a style-code index table;
[0011] The target style blocks are stored using the style-encoding index table.
[0012] Preferably, the step of combining and optimizing the various atomic-level style blocks to form various target style blocks includes:
[0013] Determine whether there are at least two atomic style blocks that belong to a preset fixed style combination among the various atomic style blocks;
[0014] If so, then merge the atomic style blocks that belong to the fixed style combinations to obtain the various style combinations;
[0015] Each of the aforementioned style combinations and all other atomic style blocks are treated as target style blocks.
[0016] Preferably, generating hash codes corresponding to each of the target style blocks includes:
[0017] For each target style block, obtain the style attributes and attribute values of that target style block;
[0018] The style attributes and attribute values are processed using a standard format, and then combined after standard format processing to obtain a string;
[0019] The string is processed using a hash algorithm to obtain the first code;
[0020] The first encoding is simplified to obtain a hash encoding.
[0021] Preferably, storing each of the target style blocks using the style-encoding index table includes:
[0022] The target style blocks are distinguished and divided into various types of target style blocks;
[0023] For each target style block in each category, extract the hash code corresponding to that target style block from the style-encoding index table;
[0024] Get the loading path corresponding to the target style block;
[0025] The target style data is obtained by marking the loading path using the hash encoding.
[0026] The target style data is stored according to the category of the target style block.
[0027] Preferably, storing the target style data according to the category of the target style block includes:
[0028] If the target style block is the active style block on the current page, then the target style data of the target style block is cached in memory, and the loading method of the memory cache is set:
[0029] When the target style block is invoked, obtain the running status of its corresponding page;
[0030] If the page is in a static state, the target style block is reused in other pages belonging to the same tab by utilizing the memory cache of the target style block;
[0031] If the current page changes from being closed or refreshed, the memory cache corresponding to the target style block will be released.
[0032] Preferably, storing the target style data according to the category of the target style block includes:
[0033] If the target style block is a site-level high-frequency style block, then the target style data of the target style block is cached on disk, and the loading method of the disk cache is set:
[0034] Set the first time period;
[0035] When the target style block is invoked, obtain the time when the invocation was initiated.
[0036] Determine whether the time of the initiation of the call is within the first time period;
[0037] If so, the disk cache of the target style block is obtained and loaded.
[0038] Secondly, a pattern storage device includes:
[0039] The decomposition module is used to obtain Cascading Style Sheet (CSS) rules and decompose the CSS rules into individual atomic-level style blocks.
[0040] The combination optimization processing module is used to combine and optimize the various atomic-level style blocks to form various target style blocks;
[0041] A hash encoding generation module is used to generate hash codes corresponding to each of the target style blocks;
[0042] An index table construction module is used to construct a style-encoding index table based on the hash encoding of each target style block;
[0043] The storage module is used to store each of the target style blocks using the style-encoding index table.
[0044] Preferably, the combined optimization processing module includes:
[0045] The judgment module is used to determine whether there are at least two atomic style blocks in each of the atomic style blocks that belong to a preset fixed style combination;
[0046] The merge module is used to merge atomic style blocks that belong to fixed style combinations to obtain individual style combinations if the condition is met.
[0047] The target style block determination module is used to take each of the style combinations and other atomic style blocks as target style blocks.
[0048] Thirdly, a type of storage device includes a memory and a processor;
[0049] The memory is used to store programs;
[0050] The processor is configured to execute the program to implement the various steps of the style storage method as described in any of the first aspects.
[0051] Fourthly, a storage medium having a computer program stored thereon, characterized in that, when the computer program is executed by a processor, it implements the steps of the pattern storage method as described in any one of the first aspects.
[0052] As can be seen from the above technical solution, this application obtains Cascading Style Sheet (CSS) rules, decomposes these rules into atomic style blocks, combines and optimizes these atomic style blocks to form target style blocks, generates hash codes corresponding to each target style block, constructs a style-code index table based on the hash codes of each target style block, and stores each target style block using the style-code index table. This application first obtains CSS rules and then decomposes them into atomic style blocks, ensuring the accuracy and efficiency of subsequent storage. The combination and optimization of the atomic style blocks reduces the storage size required for each block without affecting storage accuracy. Simultaneously, generating corresponding hash codes allows for direct storage, significantly reducing memory requirements. To ensure correspondence, a style-code index table is constructed for each hash code, and finally, the style-code index table is used for storage. This approach achieves efficient storage optimization, avoids style data redundancy, improves loading performance, and ensures normal page usage. Attached Figure Description
[0053] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0054] Figure 1 An optional flowchart of a style storage method provided in an embodiment of this application;
[0055] Figure 2This is a schematic diagram of the structure of a style storage device provided in an embodiment of this application;
[0056] Figure 3 This is a schematic diagram of the structure of a style storage device provided in an embodiment of this application. Detailed Implementation
[0057] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0058] With the rapid development of web front-end technologies, large-scale single-page applications (SPAs) and complex enterprise-level web projects are becoming increasingly common. In these projects, the size and complexity of Cascading Style Sheets (CSS) are growing exponentially. How to efficiently and maintainably manage and store style code has become a key challenge affecting front-end development efficiency and application performance.
[0059] However, existing style storage methods cannot achieve efficient storage optimization, and will still cause style data redundancy, which will lead to a significant reduction in loading performance and seriously affect the normal use of the page.
[0060] To address the shortcomings of the prior art, this invention provides a style storage method that can be applied to various computer terminals or smart terminals, and the executing entity can be the processor or server of the computer terminal or smart terminal.
[0061] This invention can be used in a wide variety of general-purpose or special-purpose computing environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor devices, distributed computing environments including any of the above devices, etc.
[0062] The flowchart of the method is as follows: Figure 1 As shown, it specifically includes:
[0063] S1: Obtain the Cascading Style Sheet (CSS) rules and break them down into individual atomic style blocks.
[0064] This step breaks down Cascading Style Sheet (CSS) rules into atomic style blocks. For example, a CSS rule (.btn { color: red; padding: 8px;}) can be broken down into color: red and padding: 8px. Atomic style blocks are indivisible atomic units. This makes CSS rules no longer component- or module-based, but property-based, thus providing a foundation for subsequent storage optimization. Only by breaking them down into the smallest units can we accurately identify which styles are duplicated, redundant, etc., thereby achieving the goal of storage optimization.
[0065] S2: Combine and optimize the various atomic-level style blocks to form various target style blocks.
[0066] This step processes each atomic-level style block, and may include:
[0067] Deduplication: For example, if multiple selectors define color: #ff0000, only one will be retained in the end, so that identical atomic style blocks can be merged;
[0068] Merge: Combine several atomic style blocks that frequently appear consecutively into a single functional block;
[0069] Compression or simplification: This allows atomic style blocks to be compressed without compromising their functionality.
[0070] Delete: Delete invalid or browser-unsupported atomic style blocks to save resources.
[0071] The above process can reduce the size of cascading style sheet rules and improve subsequent storage efficiency.
[0072] S3: Generate each hash code corresponding to each of the target style blocks.
[0073] This step is to generate a unique, fixed-length string identifier for each target style block. This is to ensure uniqueness, meaning that as long as the style content remains unchanged, the hash code will remain unchanged, avoiding naming conflicts. Furthermore, this hash code is usually used directly as the HTML class name corresponding to the target style block, thereby replacing the semantic class name manually written by the developer and further compressing the size of Cascading Style Sheet rules.
[0074] S4: Construct a style-encoding index table based on the hash encoding of each target style block.
[0075] The style-encoding index table is a mapping data structure where the key is a hash code and the value is the content of the corresponding target style block. Building this style-encoding index table is equivalent to creating a field, which can be used to quickly find the corresponding specific style text or content, thus improving efficiency.
[0076] In addition, building this table can help with fast storage and save memory.
[0077] S5: Store each of the target style blocks using the style-encoding index table.
[0078] Using a style-encoded index table to store target style blocks has two advantages: first, it stores the table itself, which contains the content of all unique atomic style blocks; second, it eliminates the use of traditional class names in HTML, instead using these hash codes as class names, thereby avoiding style data redundancy, improving loading performance, and making it suitable for large and complex web projects.
[0079] As can be seen from the above technical solution, this application obtains Cascading Style Sheet (CSS) rules, decomposes the CSS rules into atomic style blocks, combines and optimizes these atomic style blocks to form target style blocks, generates hash codes corresponding to each target style block, constructs a style-code index table based on the hash codes of each target style block, and stores each target style block using the style-code index table. This application first obtains CSS rules and then decomposes them into atomic style blocks, ensuring the accuracy and efficiency of subsequent storage. Then, it performs combination and optimization on the atomic style blocks, reducing the storage size required for each atomic style block without affecting storage accuracy. Simultaneously, it generates corresponding hash codes, which are directly used for storage in subsequent storage, significantly reducing the required memory size. To ensure correspondence, a style-code index table is constructed for each hash code, and finally, the style-code index table is used for storage. This method achieves efficient storage optimization, avoids style data redundancy, improves loading performance, and ensures normal page usage.
[0080] The method provided in this embodiment of the invention involves combining and optimizing the various atomic-level style blocks to form various target style blocks, as detailed below:
[0081] Determine whether there are at least two atomic style blocks that belong to a preset fixed style combination among the various atomic style blocks;
[0082] If so, then merge the atomic style blocks that belong to the fixed style combinations to obtain the various style combinations;
[0083] Each of the aforementioned style combinations and all other atomic style blocks are treated as target style blocks.
[0084] Specifically, considering that some styles are usually used together and are used frequently, in order to save memory, the atomic style blocks of these fixed style combinations can be merged to obtain style combinations. A style combination may contain two atomic style blocks or more atomic style blocks.
[0085] In one example, display:flexalign-items:center is combined into a style group.
[0086] The following is a detailed description of the process for generating each hash code corresponding to each of the target style blocks in this application.
[0087] For each target style block, obtain the style attributes and attribute values of that target style block;
[0088] The style attributes and attribute values are processed using a standard format, and then combined after standard format processing to obtain a string;
[0089] The string is processed using a hash algorithm to obtain the first code;
[0090] The first encoding is simplified to obtain a hash encoding.
[0091] Specifically, in one example, for a target style block (padding: 8px;), its style attribute padding and attribute value 8px are extracted. Then, the style attribute and attribute value are processed into a standard format and combined into a string. Then, a hash algorithm such as MD5 is used to calculate the first code, such as d41d8cd98f00b204e. Then, simplification is performed, such as truncating the first 6 characters, the middle 6 characters, or the last 6 characters as the final hash code, such as d41d8c. This embodiment does not impose any restrictions on this. This can greatly simplify the memory occupied by the hash code and is more reliable than using the directly generated first code.
[0092] The following embodiments provide a detailed explanation of the steps in this application for storing each of the target style blocks using the style-encoding index table.
[0093] The target style blocks are distinguished and divided into various types of target style blocks;
[0094] For each target style block in each category, extract the hash code corresponding to that target style block from the style-encoding index table;
[0095] Get the loading path corresponding to the target style block;
[0096] The target style data is obtained by marking the loading path using the hash encoding.
[0097] The target style data is stored according to the category of the target style block.
[0098] Specifically, since the target style blocks are of different types, different storage strategies can be selected according to different types during the specific storage process. Before storage, it is necessary to determine the hash code and loading path, and use the hash code to mark the loading path to obtain the target style data. In this way, the target style data can be stored by category, thereby achieving the purpose of optimizing the storage of the target style blocks.
[0099] This requires coordinating the loading path, namely, preloading the style-encoding index table during parsing, submitting style encoding requests simultaneously with DOM node creation, and completing decoding before the browser rendering engine performs style calculations; at the same time, it is necessary to inline the key style encodings for the first screen into the HTML. <style>标签,而对于非关键样式则通过requestIdleCallback在空闲时段加载,设置解码超时阈值(≤5ms),超时自动降级为其他加载方式。
[0100] 其中,按照该目标样式块的类别,对其目标样式数据进行存储的方式包括以下两种:
[0101] 1)当前页活跃样式块。
[0102] 若该目标样式块属于当前页活跃样式块,则将该目标样式块的目标样式数据进行内存缓存,并设定所述内存缓存的加载方式:
[0103] 当该目标样式块被发起调用时,获取其对应页面的运行状态;
[0104] 若所述页面为停留状态,则利用该目标样式块的内存缓存,在与所述页面属于同一标签页的其他页面中复用该目标样式块;
[0105] 若所述当前页面的运行状态变为关闭或刷新状态,则将该目标样式块对应的内存缓存进行释放。
[0106] 具体地,针对当前页活跃样式块,考虑到不管在当前页面还是同一标签页的其他页面中其应用频率均较高,因此采用内存缓存的方式,同时设定内存缓存的加载方式,即被调用时,判断页面的运行状态,根据具体的运行状态来进行不同的加载,提高灵活性。
[0107] 2)站点级高频样式块。
[0108] 若该目标样式块属于站点级高频样式块,则将该目标样式块的目标样式数据进行磁盘缓存,并设定所述磁盘缓存的加载方式:
[0109] 设置第一时间段;
[0110] 当该目标样式块被发起调用时,获取被发起调用的时间;
[0111] 判断所述被发起调用的时间是否在所述第一时间段内;
[0112] 若是,则获取该目标样式块的磁盘缓存,并对所述磁盘缓存进行加载。
[0113] 具体地,针对站点级高频样式块,采用磁盘缓存的方式,同时也设定了磁盘缓存的加载方式,即设定生命周期(第一时间段),比如30天,即无论用户访问多少次网站的任何页面,只要需要这些高频样式块,浏览器都会从本地磁盘缓存加载在目标样式块,其速度远快于网络请求;若30天后如果未使用或站点发布了新版本样式,则其磁盘缓存失效。
[0114] 除了上述两种类型的样式块,还有一种存储在IndexedDB(全域样式块编码库)中的目标样式块,其永久存储在IndexedDB数据库中,除非用户主动清除整个网站数据或清除浏览器数据缓存,否则将会一直存在。
[0115] 样式存储后针对后续的优化、更新,可以通过对比差异来实现差异化更新,提高效率;也可以在推送更新通知时触发客户端的增量同步。
[0116] 与图1所述的方法相对应,本发明实施例还提供了样式存储装置,用于对图1中方法的具体实现,本发明实施例提供的样式存储装置可以在计算机终端或各种移动设备中,结合图2,对样式存储装置进行介绍,如图2所示,该装置可以包括:
[0117] 拆解模块10,用于获取层叠样式表规则,将所述层叠样式表规则拆解为各个原子级样式块;
[0118] 组合优化处理模块20,用于将各个所述原子级样式块进行组合优化处理,以形成各个目标样式块;
[0119] 哈希编码生成模块30,用于分别生成与每一个所述目标样式块对应的各个哈希编码;
[0120] 索引表构建模块30,用于基于每一个所述目标样式块的哈希编码,构建样式-编码索引表;
[0121] 存储模块40,用于利用所述样式-编码索引表,对各个所述目标样式块进行存储。
[0122] 从上述技术方案可以看出,本申请通过获取层叠样式表规则,将所述层叠样式表规则拆解为各个原子级样式块;将各个所述原子级样式块进行组合优化处理,以形成各个目标样式块;分别生成与每一个所述目标样式块对应的各个哈希编码; 基于每一个所述目标样式块的哈希编码,构建样式-编码索引表;利用所述样式-编码索引表,对各个所述目标样式块进行存储。本申请首先获取层叠样式表规则,然后拆解为各个原子级样式块,这样可以保证后续存储过程的精准、高效,然后再对原子级样式块进行组合优化处理,组合优化处理能够减轻原子级样式块所需存储的大小,同时又不会影响存储的精准性,同时,生成对应的哈希编码,在后续存储时直接利用哈希编码进行存储,大大减少了所需存储的内存大小,为了保证对应,针对每一个哈希编码,构建样式-编码索引表,最后再利用样式-编码索引表进行存储,这种方式实现了高效的存储优化,避免了样式数据冗余,提高加载性能,保证了页面的正常使用。
[0123] 在一个示例中,所述组合优化处理模块可以包括:
[0124] 判断模块,用于判断各个所述原子级样式块中是否存在至少两个原子级样式块属于预设固定搭配的样式组合;
[0125] 合并模块,用于若是,则将各个属于固定搭配的样式组合的原子级样式块进行合并,得到各个样式组合;
[0126] 目标样式块确定模块,用于将各个所述样式组合和其他各个原子级样式块均作为目标样式块。
[0127] 更进一步地,本申请实施例提供了一种样式存储设备。可选的,图3示出了样式存储设备的硬件结构框图,参照图3,样式存储设备的硬件结构可以包括:至少一个处理器01,至少一个通信接口02,至少一个存储器03和至少一个通信总线04。
[0128] 在本申请实施例中,处理器01、通信接口02、存储器03、通信总线04的数量为至少一个,且处理器01、通信接口02、存储器03通过通信总线04完成相互间的通信。
[0129] 处理器01可以是一个中央处理器CPU,或者是特定集成电路ASIC(ApplicationSpecific Integrated Circuit),或者是被配置成实施本发明实施例的一个或多个集成电路等。
[0130] 存储器03可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatilememory)等,例如至少一个磁盘存储器。
[0131] 其中,存储器存储有程序,处理器可调用存储器存储的程序,程序用于执行下述样式存储方法,包括:
[0132] 获取层叠样式表规则,将所述层叠样式表规则拆解为各个原子级样式块;
[0133] 将各个所述原子级样式块进行组合优化处理,以形成各个目标样式块;
[0134] 分别生成与每一个所述目标样式块对应的各个哈希编码;
[0135] 基于每一个所述目标样式块的哈希编码,构建样式-编码索引表;
[0136] 利用所述样式-编码索引表,对各个所述目标样式块进行存储。
[0137] 可选的,程序的细化功能和扩展功能可参照方法实施例中的样式存储方法的描述。
[0138] 本申请实施例还提供一种存储介质,该存储介质可存储有适于处理器执行的程序,在所述程序运行时控制所述存储介质所在的设备执行下述样式存储方法,包括:
[0139] 获取层叠样式表规则,将所述层叠样式表规则拆解为各个原子级样式块;
[0140] 将各个所述原子级样式块进行组合优化处理,以形成各个目标样式块;
[0141] 分别生成与每一个所述目标样式块对应的各个哈希编码;
[0142] 基于每一个所述目标样式块的哈希编码,构建样式-编码索引表;
[0143] 利用所述样式-编码索引表,对各个所述目标样式块进行存储。
[0144] 具体地,该存储介质可以是一种计算机可读存储介质,计算机可读存储介质可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。
[0145] 可选的,程序的细化功能和扩展功能可参照方法实施例中的样式存储方法的描述。
[0146] 另外,在本公开各个实施例中的各功能模块可以集成在一起形成一个独立的部分,也可以是各个模块单独存在,也可以两个或两个以上模块集成形成一个独立的部分。功能如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,直播设备,或者网络设备等)执行本公开各个实施例方法的全部或部分步骤。
[0147] 最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语"包括”、"包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句"包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。
[0148] 本说明书中各个实施例采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似部分互相参见即可。
[0149] 对所公开的实施例的上述说明,使本领域专业技术人员能够实现或使用本申请。对这些实施例的多种修改对本领域的专业技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。< / style>
Claims
1. A style storage method, characterized in that, include: Obtain the Cascading Style Sheet (CSS) rules and break them down into individual atomic style blocks; The atomic style blocks are combined and optimized to form target style blocks; including: determining whether there are at least two atomic style blocks that belong to a preset fixed style combination; if so, merging the atomic style blocks that belong to the fixed style combination to obtain each style combination; and taking each style combination and each other atomic style block as target style blocks. Generate hash codes corresponding to each of the target style blocks; Based on the hash code of each target style block, construct a style-code index table; The target style blocks are stored using the style-encoding index table.
2. The method according to claim 1, characterized in that, The step of generating hash codes corresponding to each of the target style blocks includes: For each target style block, obtain the style attributes and attribute values of that target style block; The style attributes and attribute values are processed using a standard format, and then combined after standard format processing to obtain a string; The string is processed using a hash algorithm to obtain the first code; The first encoding is simplified to obtain a hash encoding.
3. The method according to claim 1, characterized in that, The step of storing each target style block using the style-encoding index table includes: The target style blocks are distinguished and divided into various types of target style blocks; For each target style block in each category, extract the hash code corresponding to that target style block from the style-encoding index table; Get the loading path corresponding to the target style block; The target style data is obtained by marking the loading path using the hash encoding. The target style data is stored according to the category of the target style block.
4. The method according to claim 3, characterized in that, The step of storing the target style data according to the category of the target style block includes: If the target style block is the active style block on the current page, then the target style data of the target style block is cached in memory, and the loading method of the memory cache is set: When the target style block is invoked, obtain the running status of its corresponding page; If the page is in a static state, the target style block is reused in other pages belonging to the same tab by utilizing the memory cache of the target style block; If the page's running state changes to closed or refreshed, the memory cache corresponding to the target style block is released.
5. The method according to claim 3 or 4, characterized in that, The step of storing the target style data according to the category of the target style block includes: If the target style block is a site-level high-frequency style block, then the target style data of the target style block is cached on disk, and the loading method of the disk cache is set: Set the first time period; When the target style block is invoked, obtain the time when the invocation was initiated. Determine whether the time of the initiation of the call is within the first time period; If so, the disk cache of the target style block is obtained and loaded.
6. A style storage device, characterized in that, include: The decomposition module is used to obtain Cascading Style Sheet (CSS) rules and decompose the CSS rules into individual atomic-level style blocks. A combination optimization processing module is used to perform combination optimization processing on the atomic style blocks to form target style blocks; including: a judgment module, used to determine whether there are at least two atomic style blocks in each atomic style block that belong to a preset fixed style combination; a merging module, used to merge the atomic style blocks that belong to the fixed style combination if so, to obtain each style combination; and a target style block determination module, used to take each style combination and all other atomic style blocks as target style blocks. A hash encoding generation module is used to generate hash codes corresponding to each of the target style blocks; An index table construction module is used to construct a style-encoding index table based on the hash encoding of each target style block; The storage module is used to store each of the target style blocks using the style-encoding index table.
7. A style storage device, characterized in that, Including memory and processor; The memory is used to store programs; The processor is configured to execute the program to implement the various steps of the style storage method as described in any one of claims 1-5.
8. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the various steps of the style storage method as described in any one of claims 1-5.
Citation Information
Patent Citations
Treatment method and device for cascading style sheet (CSS)
CN103064849A
Webpage loading optimization method and device, equipment and readable storage medium
CN118939898A