filter · CSS filters
Rewrite style attributes with url() (rewrite_style_attributes_with_url)
- Category:
- CSS
- CoreFilters:
- Yes
- OptimizeForBandwidth:
- No
- Risk:
- Generally safe
rewrite_style_attributes applies CSS rewriting (minification, URL rewriting) to inline style="" attributes on HTML elements. rewrite_style_attributes_with_url (Core filter) does the same but only when the style value contains a url() reference.
When to use it
- In CoreFilters, the default RewriteLevel: it runs unless you disable it.
- Risk rating on these docs: Generally safe.
Risks
The
CSS filters
page lists no specific risks for this filter.
If a page misbehaves with it, DisableFilters rewrite_style_attributes_with_url turns it off for
the scope you set it in.
Configuration
Enable it in the module configuration, at server, virtual-host or location scope:
Apache
ModPagespeedEnableFilters rewrite_style_attributes_with_urlnginx
pagespeed EnableFilters rewrite_style_attributes_with_url;IIS (pagespeed.config)
pagespeed EnableFilters rewrite_style_attributes_with_urlIt is on by default under CoreFilters; to turn it off:
ModPagespeedDisableFilters rewrite_style_attributes_with_url # Apache
pagespeed DisableFilters rewrite_style_attributes_with_url; # nginx
pagespeed DisableFilters rewrite_style_attributes_with_url # IIS
Scoping, ForbidFilters and the thresholds filters read:
Choosing filters
.
Live example
Rewrites inline style attributes only when they contain a url() reference.
This filter changes how the page is structured or delivered, not its size, so the example shows a source diff rather than a byte or request reduction.
Frequently asked questions
- What does the rewrite_style_attributes_with_url filter do?
rewrite_style_attributesapplies CSS rewriting (minification, URL rewriting) to inlinestyle=""attributes on HTML elements.rewrite_style_attributes_with_url(Core filter) does the same but only when the style value contains aurl()reference.- Is rewrite_style_attributes_with_url enabled by default?
- Yes.
rewrite_style_attributes_with_urlis in CoreFilters, the default RewriteLevel, so it runs unless you turn it off withDisableFilters. - How do I turn off rewrite_style_attributes_with_url?
- Add
ModPagespeedDisableFilters rewrite_style_attributes_with_urlon Apache orpagespeed DisableFilters rewrite_style_attributes_with_url;on nginx. On IIS, addpagespeed DisableFilters rewrite_style_attributes_with_urlto pagespeed.config.
Related filters
- rewrite_style_attributes — Rewrite style attributes
- combine_css — Combine CSS
- compute_critical_css — Compute critical CSS
- extend_cache_css — Extend cache for CSS
- fallback_rewrite_css_urls — Fallback CSS URL rewriting
- flatten_css_imports — Flatten CSS @imports
- inline_css — Inline CSS
- inline_google_font_css — Inline Google Fonts CSS
This page is drawn from the rewrite_style_attributes_with_url entry on CSS filters. Every filter in one table: PageSpeed filters.