New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagespeed eats CSS font-face declarations when defined in imported files #1222

Closed
rbu opened this Issue Jul 11, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@rbu
Copy link

rbu commented Jul 11, 2016

Given the following configuration:

    pagespeed RewriteLevel CoreFilters;
    pagespeed EnableFilters combine_css,combine_javascript;
    pagespeed EnableFilters rewrite_javascript,rewrite_css,fallback_rewrite_css_urls;
    pagespeed EnableFilters move_css_above_scripts,move_css_to_head,collapse_whitespace;

And the following files:
test.html:

<html>
    <head>
        <meta charset="utf-8" />
        <link rel="stylesheet" href="main.css">
    </head>
    <body>
        content
    </body>
</html>

main.css:

@import url('sub.css');
.after-import {
    font-family: "myfont";
    display: none;
}

sub.css:

.before-font {
    display: none;
}
@font-face {
    font-family: 'myfont';
}
.after-font {
    display: none;
}

nginx pagespeed yields:

<html>
<head>
<meta charset="utf-8"/>
<style>.before-font{display:none}.after-font{display:none}.after-import{font-family:"myfont";display:none}</style>
</head>
<body>
content
</body>
</html>

Note that this is missing the @font-face declaration. This example is minified. The @font-face actually contains source identifiers and the like. The main css file is longer (so it is not inlined), however the same issue happens. The URLs are retrievable, it works on the first load after a cache flush (before minification) and when pagespeed is disabled via the URL.

@morlovich morlovich self-assigned this Jul 11, 2016

@morlovich

This comment has been minimized.

Copy link
Contributor

morlovich commented Jul 12, 2016

Confirmed. (Thanks for the excellent testcase!)

morlovich added a commit to apache/incubator-pagespeed-mod that referenced this issue Jul 12, 2016

@morlovich

This comment has been minimized.

Copy link
Contributor

morlovich commented Jul 12, 2016

Should be fixed by the above. (It will reorder the @font-face to before .before-font, but I think that's equivalent...)

@morlovich morlovich closed this Jul 12, 2016

crowell added a commit to apache/incubator-pagespeed-mod that referenced this issue Jul 25, 2016

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