Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

CSS Minification - 0 followed by a unit is rewritten to 0 without a unit. #1538

Description

@dhaupin

I ran into this today with mod_pagespeed 1.11.33.4-0 that is packaged in cPanel experimental repo.

When using CSS minifier, 0 followed by a unit, such as 0px, is re-written into 0 without a unit. This breaks some CSS directives that always require a unit. Example is a dynamic construction of CSS that drops a 0px into a calc() when an offset is not required.

Example:
left: calc(50% - $offset);

Since its not always used, $offset is set to 0px by default, which renders as:
left: calc(50% - 0px);

Upon minification, Pagespeed truncates the px resulting in:
left: calc(50% - 0);

This is invalid and causes errors. Besides Pagespeed, this issue seems to be found in other minification applications as well. Is there any possibility to always include the unit of measurement? The spec claims unit is optional, so perhaps there should be a config for it rather than assuming "no unit" on rewrite: https://www.w3.org/TR/css3-values/#lengths

Thanks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions