Resource loading method and device for front end, equipment and medium
By obtaining the state mapping table and bit offset allocation of resources, using the mask to calculate and mark dependent resources and load them in parallel, the problem of low efficiency in front-end resource loading is solved, and an efficient and reliable resource loading process is achieved.
Patent Information
- Application Number
- CN202611224676.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-12
- Publication Date
- 2026-11-24
AI Technical Summary
Existing front-end resource loading methods are inefficient when handling complex dependencies, resulting in excessively long loading times. This is especially problematic in insurance and healthcare service scenarios, impacting work efficiency. Furthermore, parallel loading methods are complex and difficult to maintain.
By obtaining the state mapping table of the resources to be loaded, using bit offset allocation and mask calculation, resources without dependencies are marked and loaded in parallel. A global mask is used to manage the resource state, simplifying the synchronization logic and detecting circular dependencies.
It achieves an efficient resource loading process, simplifies system state management, and improves the reliability and efficiency of the loading process, making it suitable for business scenarios such as fintech and healthcare.
Smart Images

Figure CN123157283A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of front-end development technology, and in particular to a resource loading method, apparatus, device and medium for front-end. Background Technology
[0002] As the number and complexity of resources managed by modern front-end engineering grow exponentially, current mainstream resource loading methods in the front-end field still have certain limitations when facing scenarios with ultra-large-scale and fine-grained dependencies.
[0003] Currently, most resource loading methods typically employ a recursive traversal of the dependency tree, loading dependent resources layer by layer. However, when the dependency chain is long, the total loading time becomes the sum of the loading times of each individual resource, leading to excessively long loading times and impacting work efficiency. For example, in insurance service scenarios, using the traditional layer-by-layer loading method to handle complex customer policy dependency chains may result in excessively long claims or query response times, affecting service efficiency.
[0004] Furthermore, while some resource loading methods attempt to load in parallel, when dealing with dependencies in directed acyclic graphs, most require maintaining complex state machines and callback queues, resulting in high code complexity and a high risk of errors. For example, in healthcare scenarios, using state machine-based and callback queue-based methods to schedule the parallel loading of multiple patient examination dependencies leads to a complex and difficult-to-maintain system architecture, and increases the risk of errors in the diagnosis and treatment process.
[0005] Therefore, accurately determining the front-end resource loading status with complex dependencies in order to efficiently perform resource loading has become an urgent problem to be solved. Summary of the Invention
[0006] This invention provides an artificial intelligence-based method, apparatus, computer device, and medium for front-end resource loading, to solve the technical problem of accurately determining the front-end resource loading status with complex dependencies in order to efficiently execute resource loading.
[0007] Firstly, a resource loading method for the front end is provided, including: Obtain the state mapping table of the resource to be loaded, the state mapping table including the dependency relationship of the resource to be loaded and the mapping relationship between the resource identifier and the resource state of the resource to be loaded; Based on the dependency relationship, bit offsets are allocated to the resource to be loaded to obtain the allocated displacement of the resource to be loaded. Based on the dependencies and the allocated displacement, a mask calculation is performed on the resource to be loaded to obtain the pre-mask value of the resource to be loaded; Based on the premask value, the resources to be loaded that represent resources without dependencies are marked, and the marked resources are obtained; Based on the marked resources, determine the ready resources that represent loading readiness; The ready resources are loaded to obtain the loaded ready resources; Return to the step of performing mask calculation on the resources to be loaded based on the dependencies and the allocated displacement to obtain the pre-mask value of each resource to be loaded, until all the ready resources are loaded, and the resource loading is completed.
[0008] Secondly, according to an embodiment of this application, a resource loading device for a front end includes: The information acquisition module is used to acquire the status mapping table of the resource to be loaded. The status mapping table includes the dependency relationship of the resource to be loaded and the mapping relationship between the resource identifier and the resource status of the resource to be loaded. The displacement allocation module is used to allocate bit offsets to the resource to be loaded according to the dependency relationship, so as to obtain the allocated displacement of the resource to be loaded. The mask calculation module is used to perform mask calculation on the resource to be loaded based on the dependency relationship and the allocated displacement, so as to obtain the pre-mask value of the resource to be loaded. The dependency-free marking module is used to mark the resources to be loaded that represent dependency-free resources according to the pre-mask value, so as to obtain marked resources; A readiness determination module is used to determine, based on the marked resources, ready resources that represent loading readiness; A loading module is used to load the ready resources to obtain the loaded ready resources; The execution module is returned to the step of performing mask calculation on the resources to be loaded based on the dependencies and the allocated displacement to obtain the pre-mask value of each resource to be loaded, until all the ready resources are loaded and the resource loading is completed.
[0009] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the resource loading method for the front end described above.
[0010] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the resource loading method for the front end described above.
[0011] The beneficial effects of this application embodiment compared with the prior art are as follows: A state mapping table of resources to be loaded is obtained. The state mapping table includes the dependencies of the resources to be loaded and the mapping relationship between the resource identifier and the resource state. Based on the dependencies, bit offsets are allocated to the resources to be loaded to obtain the allocated displacement. Based on the dependencies and the allocated displacement, a mask calculation is performed on the resources to be loaded to obtain the pre-mask value of the resources to be loaded. Based on the pre-mask value, resources to be loaded that do not have dependencies are marked to obtain marked resources. Based on the marked resources, ready resources that are ready to be loaded are determined. The ready resources are loaded to obtain the loaded ready resources. The process returns to the previous step of calculating the mask of the resources to be loaded based on the dependencies and the allocated displacement to obtain the pre-mask value of each resource to be loaded, until all ready resources are loaded, completing the resource loading. This application can be applied to business scenarios such as fintech and healthcare. A global mask records the loaded resources, and each resource has a pre-mask representing its dependencies. The readiness check only requires one bit operation to calculate the complexity result. Meanwhile, resources without dependencies can be loaded in parallel. Once any resource is completed, the global mask is updated and the next batch of ready resources is automatically triggered, forming a highly efficient cascading mechanism. The entire system state is managed by a single number, simplifying the synchronization logic. The bit allocation mechanism based on a directed acyclic graph can handle any acyclic dependency structure, and circular dependencies are detected during initialization, ensuring the reliability and efficiency of the loading process. Attached Figure Description
[0012] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a schematic diagram of an application environment for a resource loading method for the front end provided in an embodiment of this application; Figure 2 This is a flowchart illustrating a resource loading method for a front-end provided in an embodiment of this application; Figure 3 This is a flowchart illustrating a resource loading method for a front-end provided in an embodiment of this application; Figure 4 This is a flowchart illustrating a resource loading method for a front-end provided in an embodiment of this application; Figure 5 This is a flowchart illustrating a resource loading method for a front-end provided in an embodiment of this application; Figure 6This is a schematic diagram of the structure of a resource loading device for the front end provided in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention; Figure 8 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation
[0014] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0015] This application provides a resource loading method for front-end applications, which can be applied to applications such as... Figure 1 In the application environment, the client and server interact through a communication connection. The user can trigger a resource loading request by operating the client, and the server is used to receive resource identification information containing dependencies sent by the client, and execute the resource loading method for the front end of the present invention based on these inputs.
[0016] See Figure 2 This is a flowchart illustrating a resource loading method for a front-end according to an embodiment of this application. The aforementioned resource loading method for a front-end can be applied to... Figure 1 The server-side component.
[0017] like Figure 2 As shown, the resource loading method for the front end may include the following steps: Step S201: Obtain the state mapping table of the resource to be loaded. The state mapping table includes the dependency relationship of the resource to be loaded and the mapping relationship between the resource identifier and the resource state of the resource to be loaded.
[0018] Step S202: Based on the dependency relationship, perform bit offset allocation on the resource to be loaded to obtain the allocated displacement of the resource to be loaded.
[0019] Optionally, step S202, which involves allocating bit offsets to the resource to be loaded based on the dependency relationship to obtain the allocated displacement of the resource to be loaded, may include the following steps: Based on the dependencies, determine the resource loading order of the resources to be loaded; Based on the resource loading order and a preset offset value, bit offsets are allocated to the resources to be loaded in sequence to obtain the allocated displacement of the resources to be loaded.
[0020] Specifically, the configuration information of the resources to be loaded is obtained through the resource management system, and a status mapping table is generated. The status mapping table is stored in JSON format and includes resource identifier, dependency relationship, resource status, etc.
[0021] Among them, the resource identifier refers to a string or number that uniquely identifies each resource. The dependency relationship refers to an array listing the identifiers of other resources that this resource depends on. The resource status refers to a string, with possible values including not loaded, loading, and loaded.
[0022] Based on the dependency relationship obtained in step S201, a unique bit offset is assigned to each resource. The dependency relationship is analyzed by the topological sorting algorithm. Starting from resources without dependencies, the loading order is determined step by step to generate an ordered list of resource IDs.
[0023] The bit offset is allocated by setting the initial offset value to 0 and then allocating an increasing offset in sequence according to the resource loading order. Each resource obtains a unique offset value, which is used as the index position of the binary bits.
[0024] In an optional implementation, determining the resource loading order of the resources to be loaded based on the dependency relationship specifically includes: constructing a dependency graph, with resources as nodes and dependency relationships as directed edges, calculating the in-degree (number of times each resource is depended on), and gradually generating a loading order queue starting from the resource with an in-degree of 0.
[0025] The process involves allocating bit offsets to the resources to be loaded sequentially based on the resource loading order and a preset offset value. Specifically, the initial offset value is set to 0, the resource loading order list is traversed, the current resource is allocated a displacement, and the initial offset value is increased by 1 to complete the bit offset allocation for all resources.
[0026] For example, during the resource loading process of the insurance claims system, the system obtains a complete list of materials (status mapping table) required for the claims case based on the policy number (resource identifier), including the dependencies between each material (such as the data report needing to be uploaded before the expense list) and the upload status of each material (not submitted / under review / approved); and assigns processing priority (bit offset) to the materials according to the dependencies, prioritizing medical reports with a high offset to ensure that core materials enter the review queue first.
[0027] For example, in a healthcare service scenario, an electronic medical record system retrieves a list of all examination items (status mapping table) required for the current treatment process based on the patient ID (resource identifier). This includes the dependencies between items (e.g., blood tests take precedence over CT scans) and the completion status of each item (pending appointment / in progress / report issued). Based on the dependencies, the system assigns execution sequence numbers (bit offsets) to the examination items. For example, blood tests are assigned the lowest offset to ensure that basic data is collected first.
[0028] Step S203: Based on the dependency relationship and the allocated displacement, perform mask calculation on the resource to be loaded to obtain the pre-mask value of the resource to be loaded.
[0029] Optionally, the step of calculating the mask of the resource to be loaded based on the dependency relationship and the allocated displacement to obtain the pre-mask value of the resource to be loaded may include the following steps: Based on the dependency relationship, determine the dependent resources of the resource to be loaded; Based on the allocated displacement, a bitwise OR operation is performed on the dependent resource to obtain the premask value of the resource to be loaded.
[0030] Based on the established dependencies and the displacements allocated to each resource, a mask calculation is performed on the specific resource that needs to be loaded (i.e., the resource to be loaded). The purpose is to generate a binary mask value for subsequent scheduling or conflict detection, referred to here as the pre-mask value. This process involves identifying all resources that directly affect or must be processed before the resource to be loaded, and aggregating their unique location identifiers (represented by displacements) into a comprehensive mask.
[0031] In one optional implementation, firstly, based on the dependencies of the resources to be loaded determined in the state mapping table in step S201, all direct or indirect dependent resources of the current resource to be loaded are resolved. Dependent resources refer to those resources that must be completed before the resource to be loaded in terms of loading order, initialization logic, or data preparation. The system traverses the dependency structure to retrieve the identifiers or indices of all these related resources.
[0032] A bitwise OR operation is performed to generate a pre-mask value. Specifically, for each dependent resource identified in the previous step, its pre-allocated displacement is obtained. This displacement is typically an integer (e.g., 0, 1, 2, etc.), representing the resource's specific bit position in a bitmask (e.g., displacement 0 corresponds to bit 1, displacement 1 corresponds to bit 2, and so on). Then, the system performs a bitwise OR logical operation, merging the single-bit bitmasks generated for each dependent resource based on its allocated displacement (e.g., if dependent resource A has a displacement of 2, its single-bit mask is 1 << 2 = binary 100). The specific calculation is: Pre-mask value = Mask dependent resource 1 | Mask dependent resource 2 | ... | Mask dependent resource N. Here, "|" represents the bitwise OR operator, and "<<" represents the left shift operator.
[0033] For example, in an insurance service scenario, the claims system performs logical operations on a certain material to be reviewed (such as a list of expenses) based on the dependencies between materials and the assigned processing priorities (assignment displacement). The system identifies the dependent resource as a medical report and performs a bitwise OR calculation on the priority corresponding to the medical report to generate a pre-mask value for the list of expenses. This mask value represents the mandatory logical state that "the medical report must be reviewed first".
[0034] For example, in a medical service scenario, a diagnostic system performs logical operations on a specific item to be executed (such as a CT scan) based on the dependencies between examination items and the assigned execution sequence number (assignment displacement). For instance, the system identifies that its dependent resource is a blood test and performs a bitwise OR operation on the sequence number corresponding to the blood test to generate a pre-mask value for the CT scan. This mask value represents the mandatory logical state that "the blood test must be completed and the result obtained first".
[0035] Step S204: Based on the pre-mask value, mark the resources to be loaded that represent resources without dependencies, and obtain marked resources.
[0036] Optionally, step S204, which involves marking resources to be loaded that do not have dependent resources based on the pre-mask value to obtain marked resources, may include the following steps: Perform a bitwise AND operation on the pre-mask value to obtain the mask calculation result; The mask calculation results are filtered, and the resources to be loaded with a pre-mask value of 0 are designated as the marked resources.
[0037] The process involves performing a bitwise AND operation to quickly check whether all dependencies of a resource to be loaded have been satisfied. The system performs a bitwise AND operation between the resource's pre-mask value and a completed resource mask or an available resource status mask. The completed resource mask is a dynamically updated bitmask; when each bit (corresponding to the allocation offset of a resource) is 1, it indicates that the corresponding resource has been successfully loaded, initialized, or has reached a ready state; a bit of 0 indicates that it has not yet been completed.
[0038] Select resources without dependencies as labeled resources, which means judging the mask calculation results obtained in the previous step.
[0039] For a resource to be loaded, if all its dependencies are satisfied, then all bits that are 1 in its preamble mask will also be 1 in the corresponding bits of the completed resource mask. Due to the characteristics of bitwise AND operations, this will result in the preamble mask value equal to the completed resource mask value, and this result will not be zero. Conversely, if at least one dependency is not satisfied, the bitwise AND result will not be equal to the original preamble mask value, and will usually be a small number. The most special case of no dependencies is when the preamble mask value itself is zero (i.e., all bits in binary are 0), indicating that the resource has no preamble dependencies. In this case, regardless of the value of the completed resource mask, the bitwise AND result will always be zero.
[0040] The system iterates through all resources to be loaded, checking the pre-mask value of each resource. Resources with a pre-mask value of zero are selected. These resources are ready because they have no pre-dependencies, or can be used as the starting point for the loading process at any time. These selected resources are defined as marked resources.
[0041] For example, in an insurance service scenario, the claims system performs logical filtering on all materials to be reviewed based on the calculated pre-mask values of all materials. The system performs a bitwise AND operation on the pre-mask value of each material with a specific flag, and filters out materials with a calculation result of zero. This means that the material (such as the initial claim record) has no pre-dependent resources, and the system marks it as a marked resource that can immediately enter the review process.
[0042] For example, in a medical service scenario, the diagnosis and treatment system performs logical filtering on all items to be executed based on the pre-mask values of all the examination items that have been calculated. The system performs a bitwise AND operation on the pre-mask value of each item and a specific flag, and filters out items whose calculation result is zero. This means that the item (such as basic consultation and physical examination) has no pre-dependent resources, and the system marks it as a marked resource that can be scheduled for execution immediately.
[0043] Step S205: Based on the marked resources, determine the ready resources that represent loading readiness.
[0044] Step S206: Load the ready resources to obtain the loaded ready resources.
[0045] Step S207: Return to the step of performing mask calculation on the resources to be loaded based on the dependency relationship and the allocated displacement to obtain the pre-mask value of each resource to be loaded, until all the ready resources are loaded and the resource loading is completed.
[0046] After obtaining the marked resources (i.e., those resources with a premask value of zero and no dependency constraints), the system needs to further determine the ready resources that can be loaded immediately. This step mainly involves status verification and resource selection.
[0047] Specifically, the system checks the current state of these marked resources, including availability checks and state lock checks.
[0048] Availability checks refer to confirming that the resource exists in a specified storage location (such as a local cache or server) and is accessible.
[0049] State lock check refers to confirming that the resource is not locked by other threads or processes and is in a state that can be safely loaded.
[0050] If there are multiple marked resources, they can be sorted according to preset priority rules (such as resource size, type, and business importance), and the resource with the highest priority can be selected as the ready resource. If no priority distinction is required, all marked resources can be directly identified as ready resources.
[0051] After the above checks or screenings, the final set of resources determined is the ready resource for the current round. These are resources that the system determines can be loaded immediately.
[0052] Step S206 involves performing the actual loading operation on the ready resources. The specific implementation process includes resource acquisition and loading processing.
[0053] Resource acquisition refers to the system reading data from the corresponding data source (such as the local file system, network server, or database) based on the identifier of the ready resource (such as URI, path, or unique ID). Loading processing refers to performing appropriate processing based on the resource type. For example, for code modules, this involves parsing, linking, or interpreting and executing them. For configuration files, this involves parsing and loading them into the configuration data structure in memory. For data files or media resources, this involves reading data into the memory buffer or video memory. For dependent libraries, this involves dynamic linking.
[0054] After a resource is successfully loaded, the system marks its status as loaded or completed. A key operation is to synchronously update a globally or context-shared completed resource mask. Specifically, based on the pre-allocated allocation displacement (e.g., displacement k) of the ready resource, the k-th bit (counting from the least significant bit) of the completed resource mask is set to 1. For example, if displacement k = 3, then the operation `completed resource mask = completed resource mask | (1 << 3)` is performed.
[0055] Step S207 describes the iteration and termination conditions of the loading process. After executing step S206 and updating the completed resource mask, the process returns to step S203 (i.e., re-executing the step of calculating the mask for the resources to be loaded based on the dependencies and the allocated displacement to obtain the pre-mask value of each resource to be loaded). At this time, since the dependencies of some resources (the corresponding bits in their pre-mask values) may become satisfied due to the completion of this loading, a new round of pre-mask calculation and subsequent steps will be based on the updated completed resource mask.
[0056] In the next S204 round, some resources whose prefix mask values were previously non-zero due to unmet dependencies may now have their prefix mask values changed when bitwise ANDed with the updated completed resource mask. Resources whose dependencies are now all satisfied (i.e., prefix mask value & completed resource mask == prefix mask value) will then satisfy specific conditions of the mask calculation result (in some variant implementations, this is equivalent to checking (prefix mask value & completed resource mask) == prefix mask value), thus being marked and identified as new ready resources for the next loading round.
[0057] When all the resources that need to be loaded have been successfully loaded and marked as complete, meaning that no new ready resources are being selected, or more specifically, when the completed resource mask covers the bits corresponding to all preset resource offsets, the iteration process naturally ends, and resource loading is complete.
[0058] For example, in an insurance service scenario, the claims system, based on all marked resources that can immediately proceed to review, further identifies resources that are ready to load (e.g., the claim report has been obtained completely and accurately). The system then loads the ready resource, formally importing the claim report into the core review engine to complete preliminary information extraction and case filing. After processing the above resources, the system returns to the mask calculation step, recalculates the pre-mask value of the remaining materials awaiting review, and repeatedly executes the above resource loading process until all claims materials have been processed, completing the data resource loading for the entire claims case.
[0059] For example, in a medical service scenario, the diagnosis and treatment system further determines the resources that are ready to be loaded based on all the marked resources that can be executed immediately. The system then loads the ready resources. After completing the above checks, the system returns to the mask calculation step, recalculates the pre-mask values of the remaining check items, and repeats the above task loading process until all check items have been processed, thus completing the resource loading of the entire diagnosis and treatment plan.
[0060] This application can be applied to business scenarios such as fintech and healthcare. It uses a global mask to record loaded resources, with each resource having a pre-mask representing its dependencies. Readiness checks require only one bitwise operation, resulting in a complexity of O(log n). Simultaneously, resources without dependencies can be loaded in parallel. Once any resource is completed, the global mask is updated, automatically triggering the next batch of ready resources, forming a highly efficient cascading process. The entire system state is managed by a single number, simplifying synchronization logic. The bit allocation mechanism based on a directed acyclic graph can handle any acyclic dependency structure, and circular dependencies are detected during initialization, ensuring the reliability and efficiency of the loading process.
[0061] See Figure 3 This is a flowchart illustrating a resource loading method for a front-end provided in an embodiment of this application. Figure 3 As shown, in step S206 above, before loading the ready resource to obtain the loaded ready resource, the following steps may also be included: Step S301: Determine the loading status of the ready resource according to the status mapping table.
[0062] Step S302: If the loading status is loading complete, then mark the ready resource as a loaded resource.
[0063] Step S303: Add the completed loaded resource to the marked resource, and return to the step of determining the ready resources representing loading readiness based on the marked resource, until the loading status is that the resource is not loaded, and obtain all ready resources representing loading readiness.
[0064] The system maintains a state mapping table that records the current loading status of all resources (including tagged and untagged resources). The status can be: resource not loaded, loading, loading complete, loading failed, etc. The data structure of the state mapping table can be a hash table, dictionary, or array, with resource identifiers as keys and state enumeration values as values.
[0065] After step S205 identifies a batch of ready resources, the system will query the status mapping table based on the unique identifier of each ready resource to obtain its corresponding loading status.
[0066] For ready resources whose status mapping table query result indicates that loading is complete, the system does not initiate actual loading operations (such as file reading or network requests), but instead directly marks the resource as a completed loading resource.
[0067] Subsequently, the system executes a crucial logical step: adding the completed loaded resource back into the current batch of marked resources (i.e., logically considering it as processed). This addition does not physically add the resource to the original pending list, but rather, within the logical processing of this loop, it is treated as an equivalent subsequent processing object to the marked resources filtered from S204.
[0068] After executing step S302, the process returns to execute step S205 (i.e., the step of determining the ready resources representing loading readiness based on the marked resources). However, at this time, the set of marked resources processed in step S205 has been conceptually updated, and it includes the marked resources (dependent resources) selected from S204, as well as the completed loading resources added from this sub-process (S302).
[0069] The logic of step S205 (which may include availability checks, priority sorting, etc.) will be executed again on these resources. For resources that have been loaded, since their status is known to be completed, their subsequent processing will quickly skip the loading action and directly enter the completion confirmation process (such as directly updating the completed resource mask, which is equivalent to performing a virtual load).
[0070] The loop terminates and ready resource acquisition continues within this inner loop until a ready resource, whose loading status was checked in step S301, is "unloaded" (or another status indicating that loading needs to be performed, such as "uninitialized"). When a ready resource with an "unloaded" status is found, that resource is the target that actually needs to be physically loaded. The system then exits this status check loop, obtaining a set of all ready resources whose status has been confirmed and which currently need to be actually loaded, indicating that loading is ready. Subsequently, the process continues to execute the actual loading operation in step S206.
[0071] In this embodiment, the system first filters out resources that are already in a loaded state, treating them as logically processed, and immediately releases their potentially blocking dependencies (through subsequent update masks), thereby quickly advancing the process. Actual I / O or computation operations are only triggered when a resource that truly needs to be loaded is encountered. This is particularly suitable for scenarios involving incremental loading, hot resource updates, or recovery from an interrupted loading process, improving overall loading efficiency and ensuring system state consistency.
[0072] See Figure 4 This is a flowchart illustrating a resource loading method for a front-end provided in an embodiment of this application. Figure 4 As shown, the step S206 of loading the ready resource to obtain the loaded ready resource may include the following steps: Step S401: Obtain the loading parameters of the ready resources.
[0073] Step S402: Extract the number of loading attempts and loading duration from the loading parameters.
[0074] Step S403: If the number of loading attempts and the loading duration both meet the preset loading criteria, then the ready resources are loaded to obtain the loaded ready resources.
[0075] The system predefines or dynamically maintains a set of loading parameters for each resource. These parameters describe and constrain the loading behavior of the resource. Loading parameters can be associated with resource identifiers and stored in configuration files, databases, or memory structures.
[0076] When a ready resource needs to be loaded, the system retrieves its corresponding loading parameters based on the resource's unique identifier. These parameters include at least the number of load attempts and the loading duration, and may also include other relevant parameters such as loading timeout threshold, retry latency, and priority.
[0077] From the obtained loading parameters, the system clearly analyzes the control indicators, loading times, and loading duration.
[0078] The load count refers to the total number of times the resource has been attempted to be loaded in the current session or within a recent period (including successful and failed attempts). This value is typically maintained by a counter and increments after each load attempt (regardless of the outcome).
[0079] Loading time refers to the estimated or historical average loading time, which is the estimated loading time based on the resource type, size, or historical records. It also includes the time elapsed for a single load (more commonly used to prevent blocking), which is the time elapsed since the start of this loading attempt.
[0080] The system has a set of pre-defined loading criteria to determine whether to allow or continue the current loading operation.
[0081] The loading count standard is represented by a maximum retry limit. For example, the default standard is a maximum of 3 loading attempts. If the loading count is less than the default maximum, it meets the standard; otherwise, it is considered non-compliant and may trigger a loading failure handling process (such as logging errors or using backup resources).
[0082] The loading time standard is expressed as a maximum allowed loading time (timeout threshold). For example, the preset standard is that the maximum loading time for a single load should not exceed 5000 milliseconds. The system determines whether the loading time is less than the preset timeout threshold, and whether it meets the time standard. If loading has not yet started, the time standard may be met by default, or it may be compared with the expected time.
[0083] If both the number of loading attempts and the loading duration meet the preset loading criteria, the loading operation is permitted to continue. The process will execute the actual resource acquisition, data reading, and processing logic, ultimately obtaining the loaded, ready resources.
[0084] In the exception handling path, if either the number of load attempts or the loading time does not meet the preset criteria (e.g., the retries have been exhausted, or the current loading has timed out), the system will not execute or continue the current loading operation. Instead, it will switch to the exception handling branch, for example, marking the resource loading as failed.
[0085] Optionally, trigger a degradation strategy (such as loading a lighter alternative resource). Update the resource status to error. Report the exception to the monitoring system. The process may continue processing other ready resources, or, depending on the overall process design, terminate the entire loading process.
[0086] This application's embodiments effectively prevent infinite retry loops caused by network fluctuations, temporary resource unavailability, and other issues by checking the number of load attempts, protecting the system from resource exhaustion. By checking the loading duration (especially as a timeout monitoring function), it ensures that the loading of a single resource does not block the entire loading pipeline for an extended period, improving the system's responsiveness and predictability. The combination of these two aspects makes the resource loading process more robust and controllable.
[0087] See Figure 5 This is a flowchart illustrating a resource loading method for a front-end provided in an embodiment of this application. Figure 5 As shown, after the resource loading is completed, step S207 may further include the following steps: Step S501: Traverse the resource states in the state mapping table to obtain all unsuccessful resources with loading failure states.
[0088] Step S502: Analyze the unsuccessful resources according to the preset analysis criteria to obtain resource analysis results.
[0089] Step S503: Based on the resource analysis results, execute the preset loading adjustment strategy.
[0090] After the main resource loading loop is completed, the system traverses the state mapping table. The state mapping table records the resource status of all resources, such as loading complete, loading in progress, resource not loaded, loading failed, etc.
[0091] The system filters out all resources with a loading failure status, classifying them as unsuccessful resources. This identification process can be accomplished by traversing the key-value pairs in the status mapping table and checking if the status value is a loading failure or a similar error flag.
[0092] The system analyzes each or every type of unsuccessful resource identified based on preset analysis criteria. These criteria may include, but are not limited to, failure reason code analysis, failure mode statistics, resource dependency impact analysis, and environmental factor correlation.
[0093] Failure reason code analysis refers to checking the error codes or exception information associated with the loading failure status (such as network timeout, insufficient permissions, insufficient disk space).
[0094] Failure mode statistics refer to counting the number of retries for the same failed resource, or counting the failure frequency of the same type of resource (such as all image resources or all resources from a specific domain) within a recent period.
[0095] Resource dependency impact analysis refers to analyzing which subsequent resources that depend on a failed resource cannot be loaded due to the failure to load the "unsuccessful resource" (dependency chain analysis).
[0096] Environmental factor correlation refers to the analysis in conjunction with system environment information at the time of loading (such as network strength and memory usage).
[0097] By applying one or more of the above analytical criteria, the system obtains resource analysis results. These results are a structured conclusion.
[0098] Based on the resource analysis results obtained in step S502, the system executes a preset loading adjustment strategy. The preset strategy is associated with different analysis result modes.
[0099] For occasional failures (such as a single network fluctuation), the strategy might be to reset the state of the specific unsuccessful resource to "resource not loaded" after a short delay and re-add it to the loading queue (e.g., to retry in subsequent process iterations or when manually triggered by the user).
[0100] For persistent failures (such as permanent removal of a resource), a pre-prepared backup resource with similar functionality or content (a downgraded version, a locally cached version, or a generic placeholder) can be loaded. If the resource is a critical feature dependency and no backup resource is available, the system may disable related modules that depend on that feature and report the limited functionality to the user.
[0101] For systemic failures of a specific source or type (such as a CDN failure), dynamically modify the resource loading configuration to switch subsequent requests to the same source to an alternative mirror address or alternative service provider.
[0102] In response to the failure of a resource dependency link, the strategy may involve marking the entire dependency subgraph as unavailable and attempting to load an optional, standalone alternative feature package.
[0103] After implementing the adjustment strategy, the system typically updates the state mapping table, resource configuration, or loading context to reflect the adjusted state and subsequent loading logic. In some implementations, the execution of step S503 may trigger a new, targeted resource loading attempt or a system configuration update.
[0104] In this embodiment of the application, by analyzing failure modes and executing predefined coping strategies, the system is equipped with the ability to partially recover from failures, optimize subsequent behavior, or gracefully degrade, thereby improving the end-user experience and the overall robustness of the system.
[0105] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0106] In one embodiment, a resource loading device for a front-end is provided, which corresponds one-to-one with the resource loading method for a front-end in the above embodiments. For example... Figure 6 As shown, the resource loading device for the front end includes an information acquisition module 61, a displacement allocation module 62, a mask calculation module 63, a dependency-free marker module 64, a readiness determination module 65, a loading module 66, and a return execution module 67. Detailed descriptions of each functional module are as follows: The information acquisition module 61 is used to acquire the status mapping table of the resource to be loaded, the status mapping table including the dependency relationship of the resource to be loaded and the mapping relationship between the resource identifier and the resource status of the resource to be loaded; The displacement allocation module 62 is used to allocate bit offsets to the resource to be loaded according to the dependency relationship, so as to obtain the allocated displacement of the resource to be loaded. The mask calculation module 63 is used to perform mask calculation on the resource to be loaded according to the dependency relationship and the allocated displacement, so as to obtain the pre-mask value of the resource to be loaded. The dependency-free marking module 64 is used to mark the resource to be loaded, which represents a dependency-free resource, according to the pre-mask value, so as to obtain the marked resource; The readiness determination module 65 is used to determine, based on the marked resources, the ready resources that represent loading readiness; Loading module 66 is used to load the ready resources to obtain the loaded ready resources; Return to execution module 67, which is used to return to the step of performing mask calculation on the resources to be loaded according to the dependency relationship and the allocated displacement to obtain the pre-mask value of each resource to be loaded, until all the ready resources are loaded and the resource loading is completed.
[0107] Optionally, the displacement allocation module 62 includes: The sequence determination unit is used to determine the resource loading order of the resources to be loaded based on the dependency relationship; The sequential configuration unit is used to allocate bit offsets to the resources to be loaded sequentially according to the resource loading order and a preset offset value, so as to obtain the allocated displacement of the resources to be loaded.
[0108] Optionally, the mask calculation module 63 includes: The resource to be loaded determination unit is used to determine the dependent resources of the resource to be loaded based on the dependency relationship. The bitwise OR calculation unit is used to perform a bitwise OR calculation on the dependent resource according to the allocated displacement amount to obtain the premask value of the resource to be loaded.
[0109] Optionally, the dependency-free tagging module 64 includes: The bitwise AND calculation unit is used to perform bitwise AND calculations on the pre-mask value to obtain the mask calculation result; The filtering unit is used to filter the mask calculation results and select the resources to be loaded with a pre-mask value of 0 as the marked resources.
[0110] Optionally, the resource loading device further includes: The state determination module is used to determine the loading state of the ready resource according to the state mapping table before loading the ready resource to obtain the loaded ready resource; A loading flag module is used to mark the ready resource as a loaded resource if the loading status is loading complete. The loading completion module is used to add the completed loading resources to the marked resources, return to execute the step of determining the ready resources representing loading readiness based on the marked resources, until the loading status is that the resources are not loaded, and obtain all ready resources representing loading readiness.
[0111] Optionally, the loading module 66 includes: A parameter acquisition unit is used to acquire the loading parameters of the ready resources; The parameter extraction unit is used to extract the number of loading times and loading duration from the loading parameters; The ready loading unit is used to load the ready resource if both the number of loading times and the loading time meet the preset loading criteria, so as to obtain the loaded ready resource.
[0112] Optionally, the resource loading device further includes: The unsuccessful determination module is used to traverse the resource status in the status mapping table after the resource loading is completed to obtain all unsuccessful resources with loading failure status; The analysis module is used to analyze the unsuccessful resources according to preset analysis criteria and obtain resource analysis results. The strategy execution module is used to execute a preset loading adjustment strategy based on the resource analysis results.
[0113] This invention provides a resource loading device for the front end. It records loaded resources using a global mask, and each resource has a pre-mask representing its dependencies. Readiness checks require only a single bitwise operation to calculate the complexity. Simultaneously, resources without dependencies can be loaded in parallel. Once any resource is completed, the global mask is updated, automatically triggering the next batch of ready resources, forming an efficient cascading mechanism. The entire system state is managed by a single number, simplifying synchronization logic. The bit allocation mechanism based on a directed acyclic graph can handle any acyclic dependency structure, and circular dependencies are detected during initialization, ensuring the reliability and efficiency of the loading process.
[0114] Specific limitations regarding the resource loading device used for the front end can be found in the limitations regarding the resource loading method used for the front end mentioned above, and will not be repeated here. Each module in the aforementioned resource loading device for the front end can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0115] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements a resource loading method for the front end, and the functions or steps on the server side are performed.
[0116] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 8 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements a resource loading method for the front end, and the functions or steps on the client side are implemented. In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: Obtain the state mapping table of the resource to be loaded, the state mapping table including the dependency relationship of the resource to be loaded and the mapping relationship between the resource identifier and the resource state of the resource to be loaded; Based on the dependency relationship, bit offsets are allocated to the resource to be loaded to obtain the allocated displacement of the resource to be loaded. Based on the dependencies and the allocated displacement, a mask calculation is performed on the resource to be loaded to obtain the pre-mask value of the resource to be loaded; Based on the premask value, the resources to be loaded that represent resources without dependencies are marked, and the marked resources are obtained; Based on the marked resources, determine the ready resources that represent loading readiness; The ready resources are loaded to obtain the loaded ready resources; Return to the step of performing mask calculation on the resources to be loaded based on the dependencies and the allocated displacement to obtain the pre-mask value of each resource to be loaded, until all the ready resources are loaded, and the resource loading is completed.
[0117] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor: Obtain the state mapping table of the resource to be loaded, the state mapping table including the dependency relationship of the resource to be loaded and the mapping relationship between the resource identifier and the resource state of the resource to be loaded; Based on the dependency relationship, bit offsets are allocated to the resource to be loaded to obtain the allocated displacement of the resource to be loaded. Based on the dependencies and the allocated displacement, a mask calculation is performed on the resource to be loaded to obtain the pre-mask value of the resource to be loaded; Based on the premask value, the resources to be loaded that represent resources without dependencies are marked, and the marked resources are obtained; Based on the marked resources, determine the ready resources that represent loading readiness; The ready resources are loaded to obtain the loaded ready resources; Return to the step of performing mask calculation on the resources to be loaded based on the dependencies and the allocated displacement to obtain the pre-mask value of each resource to be loaded, until all the ready resources are loaded, and the resource loading is completed.
[0118] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0119] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0120] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0121] It should be noted that any AI models, software tools, or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with the knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.
[0122] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A resource loading method for a front-end, characterized in that, include: Obtain the state mapping table of the resource to be loaded, the state mapping table including the dependency relationship of the resource to be loaded and the mapping relationship between the resource identifier and the resource state of the resource to be loaded; Based on the dependency relationship, bit offsets are allocated to the resource to be loaded to obtain the allocated displacement of the resource to be loaded. Based on the dependencies and the allocated displacement, a mask calculation is performed on the resource to be loaded to obtain the pre-mask value of the resource to be loaded; Based on the premask value, the resources to be loaded that represent resources without dependencies are marked, and the marked resources are obtained; Based on the marked resources, determine the ready resources that represent loading readiness; The ready resources are loaded to obtain the loaded ready resources; Return to the step of performing mask calculation on the resources to be loaded based on the dependencies and the allocated displacement to obtain the pre-mask value of each resource to be loaded, until all the ready resources are loaded, and the resource loading is completed.
2. The resource loading method for the front end according to claim 1, characterized in that, The step of allocating bit offsets to the resource to be loaded based on the dependency relationship to obtain the allocated displacement of the resource to be loaded includes: Based on the dependencies, determine the resource loading order of the resources to be loaded; Based on the resource loading order and a preset offset value, bit offsets are allocated to the resources to be loaded in sequence to obtain the allocated displacement of the resources to be loaded.
3. The resource loading method for the front end according to claim 1, characterized in that, The step of calculating the mask of the resource to be loaded based on the dependency relationship and the allocated displacement to obtain the premask value of the resource to be loaded includes: Based on the dependency relationship, determine the dependent resources of the resource to be loaded; Based on the allocated displacement, a bitwise OR operation is performed on the dependent resource to obtain the premask value of the resource to be loaded.
4. The resource loading method for the front end according to claim 1, characterized in that, The step of marking resources to be loaded that do not have dependent resources based on the premask value to obtain marked resources includes: Perform a bitwise AND operation on the pre-mask value to obtain the mask calculation result; The mask calculation results are filtered, and the resources to be loaded with a pre-mask value of 0 are designated as the marked resources.
5. The resource loading method for the front end according to claim 1, characterized in that, Before loading the ready resource to obtain the loaded ready resource, the method further includes: The loading status of the ready resources is determined according to the state mapping table; If the loading status is "loading complete", then mark the ready resource as a resource that has been loaded. The completed loaded resources are added to the marked resources, and the process returns to the step of determining the ready resources that are ready to be loaded based on the marked resources, until the loading status is that the resources are not loaded, thus obtaining all ready resources that are ready to be loaded.
6. The resource loading method for the front end according to claim 1, characterized in that, The process of loading the ready resources to obtain the loaded ready resources includes: Obtain the loading parameters of the ready resources; Extract the number of loads and the loading duration from the loading parameters; If both the number of loading attempts and the loading duration meet the preset loading criteria, then the ready resources are loaded to obtain the loaded ready resources.
7. The resource loading method for the front end according to claim 1, characterized in that, After the resource loading is complete, the following is also included: Traverse the resource states in the state mapping table to obtain all unsuccessful resources with loading failure states; Based on preset analysis criteria, the unsuccessful resources are analyzed to obtain resource analysis results; Based on the resource analysis results, a preset loading adjustment strategy is executed.
8. A resource loading device for a front-end, characterized in that, include: The information acquisition module is used to acquire the status mapping table of the resource to be loaded. The status mapping table includes the dependency relationship of the resource to be loaded and the mapping relationship between the resource identifier and the resource status of the resource to be loaded. The displacement allocation module is used to allocate bit offsets to the resource to be loaded according to the dependency relationship, so as to obtain the allocated displacement of the resource to be loaded. The mask calculation module is used to perform mask calculation on the resource to be loaded based on the dependency relationship and the allocated displacement, so as to obtain the pre-mask value of the resource to be loaded. The dependency-free marking module is used to mark the resources to be loaded that represent dependency-free resources according to the pre-mask value, so as to obtain marked resources; A readiness determination module is used to determine, based on the marked resources, ready resources that represent loading readiness; A loading module is used to load the ready resources to obtain the loaded ready resources; The execution module is returned to the step of performing mask calculation on the resources to be loaded based on the dependencies and the allocated displacement to obtain the pre-mask value of each resource to be loaded, until all the ready resources are loaded and the resource loading is completed.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the resource loading method for the front end as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the resource loading method for the front end as described in any one of claims 1 to 7.
