less
  1. less-merge-space

Merge Space - (less-merge)

The Merge Space feature in less-merge is used to merge consecutive white spaces in CSS files to produce a smaller and more optimized output. In this tutorial, we'll discuss the syntax, example, output, explanation, use, important points, and summary of Merge Space in less-merge.

Syntax

lessc --clean-css="--s0" input.less output.css

Example

Let's use Merge Space to merge consecutive white spaces in a CSS file:

.selector {
  font-size: 16px;
  color: #333;
  margin: 10px  20px  30px;
}
lessc --clean-css="--s0" input.less output.css

The output of this command would be:

.selector{font-size:16px;color:#333;margin:10px 20px 30px}

Explanation

In this example, we used the --clean-css="--s0" option in the lessc command to turn on the "safe" mode in clean-css, which activates Merge Space. This option tells the optimizer to remove any extra spaces and compact the output CSS.

Use

Merge Space is used to optimize and compress CSS files by removing any extra spaces between selectors, properties, and values. This produces a smaller output file and reduces load times for web pages.

Important Points

  • Merge Space is a safe optimization that does not affect the layout or styling of the CSS file.
  • The --s0 option in clean-css tells the optimizer to remove any extra spaces between selectors, properties, and values.
  • Use lessc command to run Merge Space in less-merge.

Summary

In this tutorial, we discussed Merge Space in less-merge, the syntax, example, output, explanation, use, and important points of this feature. By using Merge Space, you can optimize and compress your CSS files to produce a smaller output file and reduce load times for your web pages.

Published on: