Methods of Automated CSS Refactoring for Web Application Performance Optimization

Authors

  • Evgeny Klimenchenko Software Engineer, JPMorgan, London, UK

Keywords:

CSS Optimization, Web Performance, Automated Refactoring

Abstract

This paper investigates the effectiveness of automated CSS refactoring techniques in optimizing web application performance. Focusing on two key methods - removal of unused CSS and implementation of scoped CSS - the study conducts experiments on both dynamic and static web pages. Performance metrics such as First Contentful Paint (FCP) and Largest Contentful Paint (LCP) are used to measure the impact of these techniques. The results reveal that removing unused CSS consistently improves performance, with a 4.77% decrease in loading time for dynamic pages and a 3.58% decrease for static pages. Surprisingly, the implementation of scoped CSS led to slight performance degradations in the test environment. This research provides insights into the relative effectiveness of these automated CSS optimization strategies and highlights the need for context-specific testing in web development practices. The findings contribute to the ongoing discussion on best practices for CSS performance optimization in modern web applications.

References

Google, "Optimize resource loading," web.dev. [Online]. Available: https://web.dev/learn/performance/optimize-resource-loading. [Accessed: 05-Sep-2024].

Google/SOASTA Research, 2017. [Online]. Available: https://www.thinkwithgoogle.com/marketing- strategies/app-and-mobile/page-load-time-statistics/. [Accessed: 05-Sep-2024].

Tailwindcss Documentation [Online]. Available https://tailwindcss.com/docs/installation. [Accessed: 05- Sep-2024]

E. J. Etemad and T. Atkins Jr., Selectors Level 4. W3C, Mar. 2024. [Online]. Available: https://drafts.csswg.org/selectors/#specificity-rules [Accessed: 06-Sep-2024]

S. Kuparinen, Improving Web Performance by Optimizing Cascading Style Sheets (CSS): Literature Review and Empirical Findings, Master’s thesis, Faculty of Science, University of Helsinki, Helsinki, Finland, May 2023. [PDF]. Available: https://helda.helsinki.fi/server/api/core/bitstreams/694695cf-1bdf-4432-b255- f68d6bdb4b76/content

"Study: Web Users Prefer Speed Over Customization," Website Optimization, Aug. 12, 2018. [Online]. Available: https://www.websiteoptimization.com/speed/tweak/design-factors/ [Accessed: 06-Sep-2024]

J. R. Lewis and M. Moscovitz, "Optimizing CSS for Performance," in AdvancED CSS, Apress, 2009, pp. 275–289. [Online]. Available: https://doi.org/10.1007/978-1-4302-1933-0_10 [Accessed: 06-Sep-2024]

P. Walton, "First Contentful Paint (FCP)," web.dev, Dec. 6, 2023. [Online]. Available: https://web.dev/articles/fcp [Accessed: 06-Sep-2024]

P. Walton, "Largest Contentful Paint (LCP)," web.dev, Feb. 19, 2024. [Online]. Available: https://web.dev/articles/lcp [Accessed: 06-Sep-2024]

P. Walton and M. Mihajlija, "Cumulative Layout Shift (CLS)," web.dev, Apr. 12, 2023. [Online]. Available: https://web.dev/articles/cls [Accessed: 06-Sep-2024]

P. Walton, "Time to Interactive (TTI)," web.dev, Nov. 17, 2023. [Online]. Available: https://web.dev/articles/tti [Accessed: 06-Sep-2024]

"Using Shadow DOM," MDN Web Docs, Aug. 30, 2024. [Online]. Available: https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM [Accessed: 09- Sep-2024]

"@scope," Can I use, Aug. 2024. [Online]. Available: https://caniuse.com/?search=@scope [Accessed: 09-Sep-2024]

C. Coyier, "Style Scoped," chriscoyier.net, Oct. 19, 2023. [Online]. Available: https://chriscoyier.net/2023/10/19/style-scoped/ [Accessed: 09-Sep-2024]

"@scope," MDN Web Docs, Sep. 9, 2024. [Online]. Available: https://developer.mozilla.org/en- US/docs/Web/CSS/@scope [Accessed: 09-Sep-2024]

C. Coyier, "How Do You Remove Unused CSS From a Site?" CSS-Tricks, Nov. 29, 2019. [Online]. Available: https://css-tricks.com/how-do-you-remove-unused-css-from-a-site/ [Accessed: 11-Sep-2024]

"CSS Performance Optimization," MDN Web Docs, Sep. 9, 2024. [Online]. Available: https://developer.mozilla.org/en-US/docs/Learn/Performance/CSS [Accessed: 11-Sep-2024]

"Optimizing for Production," Tailwind CSS v2 Documentation, Aug. 2024. [Online]. Available: https://v2.tailwindcss.com/docs/optimizing-for-production#basic-usage [Accessed: 11-Sep-2024]

"PurgeCSS - Documentation" PurgeCSS, Aug. 2024. [Online]. Available: https://purgecss.com/introduction.html [Accessed: 11-Sep-2024]

Dzheky, CSS Refactoring Test, GitHub. [Online]. Available: https://github.com/Dzheky/css_refactoring_test [Accessed: 13-Sep-2024]

Vercel, Serve, GitHub. [Online]. Available: https://github.com/vercel/serve [Accessed: 14-Sep-2024]

"PostCSS - A Tool for Transforming CSS with JavaScript," PostCSS, Aug. 2024. [Online]. Available: https://postcss.org/ [Accessed: 14-Sep-2024]

Alexander Madyankin, postcss-modules, GitHub. [Online]. Available: https://github.com/madyankin/postcss-modules

Downloads

Published

2024-10-07

Issue

Section

Articles

How to Cite

Evgeny Klimenchenko. (2024). Methods of Automated CSS Refactoring for Web Application Performance Optimization. International Journal of Computer (IJC), 51(1), 189-204. https://www.ijcjournal.org/InternationalJournalOfComputer/article/view/2280