TL;DR
Muzeel is a dynamic JavaScript analyzer that uses an automated "interaction bot" to identify and strip away unused code (dead code) from modern web pages. By emulating complex user interactions and handling event dependencies, it reduces page sizes by 60% and speeds up mobile page loads by up to 30%.
What Problem Does This Paper Address?
Modern web development relies heavily on massive, general-purpose JavaScript libraries. While convenient for developers, this practice leads to significant "web bloat": browsers often download and parse thousands of functions that are never actually executed.
This unused "dead code" is particularly punishing for users on low-end mobile devices and slow networks, as the browser must still process the entire script before the page becomes interactive. Existing solutions fall short: static analysis struggles with JavaScript’s dynamic nature, and previous dynamic tools often stop analyzing once the page finishes loading, mistakenly labeling code triggered by user interactions (like clicking a menu) as "dead."
Methods
The authors propose Muzeel (Arabic for "eliminator"), a system designed to run at the CDN (Content Delivery Network) level. Its workflow consists of three main phases:
- Pre-processing: Muzeel instruments the page's JavaScript, assigning a unique ID to every function and adding a small snippet of code that logs to the console whenever a function is called.
- Dead Code Discovery: This is the core innovation. Muzeel uses an Interaction Bot to load the page in an automated browser. The bot identifies all interactive elements (buttons, links, etc.) using XPaths. Crucially, it uses a breadth-first search algorithm to handle event dependencies. For example, it knows it must click a "More" menu to reveal and test the sub-buttons hidden within it.
- Elimination: After the bot has triggered every possible interaction, Muzeel reviews the logs. Any function ID that never appeared in the console is deemed "dead" and is stripped from the final JavaScript files served to the user.
Datasets
The researchers evaluated Muzeel using:
- 40,000 popular web pages from Alexa’s top 1M list to quantify the prevalence of dead code.
- A subset of 200 pages for rigorous performance benchmarking.
- Test Hardware: A range of Android devices, from the low-end Redmi Go and Samsung J3 to the high-end Samsung S10, tested across emulated 3G, LTE, and LTE+ networks.
Key Insights and Ideas
- The 70/60 Rule: The study found that on a median web page, 70% of JavaScript functions are unused, and removing them reduces the total page size by 60%.
- Interactivity is the Blind Spot: Most optimization tools fail because they don't account for code that only runs when a user interacts with the page. Muzeel’s bot-driven approach ensures these "interaction-only" functions are preserved.
- Handling Hidden Elements: Many page elements are "hidden" until a specific action occurs (see Figure 2 below). Muzeel’s dependency-aware bot ensures these hidden paths are explored, preventing the accidental deletion of functional code.
- CDN-Level Efficiency: Because 99% of a page's optimized JavaScript remains valid for at least a week, Muzeel only needs to re-analyze pages periodically, making it a viable background service for CDNs.
Key Results
- Significant Speedups: On low-end phones under 3G networks, Muzeel improved Page Load Time (PLT) by 30%. High-end phones saw a 25% improvement.
- Better User Experience: The Speed Index (a measure of how quickly the visual parts of a page appear) improved by 21-23%.
- Size Reduction: Muzeel achieved a median reduction of 0.8 MB per page.
- Superiority over State-of-the-Art: When compared to Lacuna (a prominent academic dynamic analyzer), Muzeel improved the median PLT by over 7 seconds while maintaining higher structural and functional similarity to the original pages.
Limitations and Future Work
- Third-Party Constraints: Muzeel cannot currently optimize copyrighted third-party scripts (like Google Analytics) unless the website owner hosts them locally, as the CDN lacks the authority to modify external files.
- Analysis Overhead: It takes between 5 and 20 minutes to fully analyze a single page. While acceptable for a CDN background process, it is not yet fast enough for real-time optimization of rapidly changing content.
- Complex State Machines: While the bot handles event dependencies well, extremely complex Single Page Applications (SPAs) with deep internal states may still present edge cases where code is incorrectly identified as dead.
Summary updated