CSS Minification via Constraint Solving

Author:

Hague Matthew1,Lin Anthony W.2,Hong Chih-Duo3

Affiliation:

1. Royal Holloway, University of London, Egham, UK

2. TU Kaiserslautern and University of Oxford

3. University of Oxford, Oxford, UK

Abstract

Minification is a widely accepted technique that aims at reducing the size of the code transmitted over the web. This article concerns the problem of semantic-preserving minification of Cascading Style Sheets (CSS)—the de facto language for styling web documents—based on merging similar rules. The cascading nature of CSS makes the semantics of CSS files sensitive to the ordering of rules in the file. To automatically identify rule-merging opportunities that best minimise file size, we reduce the rule-merging problem to a problem concerning “CSS-graphs,” i.e., node-weighted bipartite graphs with a dependency ordering on the edges, where weights capture the number of characters. Constraint solving plays a key role in our approach. Transforming a CSS file into a CSS-graph problem requires us to extract the dependency ordering on the edges (an NP-hard problem), which requires us to solve the selector intersection problem. To this end, we provide the first full formalisation of CSS3 selectors (the most stable version of CSS) and reduce their selector intersection problem to satisfiability of quantifier-free integer linear arithmetic, for which highly optimised SMT-solvers are available. To solve the above NP-hard graph optimisation problem, we show how Max-SAT solvers can be effectively employed. We have implemented our rule-merging algorithm and tested it against approximately 70 real-world examples (including examples from each of the top 20 most popular websites). We also used our benchmarks to compare our tool against six well-known minifiers (which implement other optimisations). Our experiments suggest that our tool produced larger savings. A substantially better minification rate was shown when our tool is used together with these minifiers.

Funder

H2020 European Research Council

Google

Engineering and Physical Sciences Research Council

Publisher

Association for Computing Machinery (ACM)

Subject

Software

Reference73 articles.

1. Alexa Internet. 2017. Alexa Top 500 Global Sites. Retrieved from https://www.alexa.com/topsites. Alexa Internet. 2017. Alexa Top 500 Global Sites. Retrieved from https://www.alexa.com/topsites.

2. Tab Atkins Jr. Elika J. Etemad and Florian Rivoal. 2017. CSS Snapshot 2017. Retrieved from https://www.w3.org/TR/css-2017. Tab Atkins Jr. Elika J. Etemad and Florian Rivoal. 2017. CSS Snapshot 2017. Retrieved from https://www.w3.org/TR/css-2017.

3. XPath satisfiability in the presence of DTDs

Cited by 4 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

1. A longitudinal analysis of bloated Java dependencies;Proceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering;2021-08-18

2. Reasoning about recursive tree traversals;Proceedings of the 26th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming;2021-02-17

3. Chapter 24. Maximum Satisfiabiliy;Frontiers in Artificial Intelligence and Applications;2021-02-02

4. Challenges of Resolving Merge Conflicts: A Mining and Survey Study;IEEE Transactions on Software Engineering;2021

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3