An Optimization Method of Javascript Redundant Code Elimination based On Hybrid Analysis Technique

Qiong Gao, Wenmin Li · 2020

Many websites import large JavaScript (JS) libraries to speed up development time and enhance user experience. However, many JS libraries that only partially utilized during page loading are all packaged into bundles. Redundant JS code inflates the page weight, which inflates the time it takes to download, parse, and compile JS resources. Therefore, it is very important to optimize the payload of JS resources to improve Web performance. This paper proposes a scheme combining static structure analysis technique and dynamic tracking technique to identify unused code during application execution and optimize the size of application bundle. Through the dependency relationship between the third-party libraries, this paper designed an analysis structure, which extract various types of function information to improve the redundant functions detection efficiency. After that, in the construction of the application bundle, this paper eliminated the redundant JS code. Our experiments show that the scheme is simple and effective, and reduces the amount of code in the bundle by 32.64% on average, and improves the accuracy by 23% on average compared with the coverage API redundancy detection tool. On the basis of ensuring the robustness of the code, the loading performance of the application is optimized.

Read the paper · More papers on PaperTik