Apache module for rewriting web pages to reduce latency and bandwidth

mod_pagespeed is an open-source Apache module created by Google to help Make the Web Faster by rewriting web pages to reduce latency and bandwidth.

PageSpeed Filter Examples

Here are some of the most useful PageSpeed filters. Each one has a simple HTML example attached; click "before" to see the original file, and "after" to see what PageSpeed produces with that filter (and only that filter) enabled. The two versions should look exactly the same, but the "after" one will be (slightly) speedier. Use "view source" to see the PageSpeed difference!

add_instrumentation Adds client-side latency instrumentation. before after
canonicalize_javascript_libraries Recognizes common JavaScript libraries and redirects each to a canonical URL. before after
collapse_whitespace Removes unnecessary whitespace in HTML. before after
combine_css Combines multiple CSS files into one. before after
combine_heads Combines multiple <head> elements into one. before after
combine_javascript Combines multiple JavaScript files into one. before after
dedup_inlined_images Replaces repeated inlined images with JavaScript that loads the data from the first instance of the image. before after
defer_javascript Defers the execution of javascript in the HTML. before after
elide_attributes Removes unnecessary attributes in HTML tags. before after
pedantic Adds default type attributes to script and style tags that are missing them. before after
extend_cache Improves cacheability. before after
extend_cache_pdfs Improves cacheability of PDFs. before after
fallback_rewrite_css_urls Rewrite URLs in CSS even if CSS is not parseable. before after
flatten_css_imports Flattens @import rules in CSS by replacing the rule with the contents of the imported resource. before after
inline_css Inlines small external CSS files. before after
inline_google_font_css Inlines small font-loading CSS from Google Fonts API. before after
inline_import_to_link Inlines style tags comprising only CSS @imports by converting them to an equivalent link. before after
inline_javascript Inlines small external Javascript files. before after
inline_preview_images Delays original images; serves inlined, low-quality placeholder images until originals are loaded. before after
insert_dns_prefetch Injects <link rel="dns-prefetch" href="//"> tags in the HEAD to enable the browser to do DNS prefetching. before after
insert_ga Inserts Google Analytics javascript snippet. before after
lazyload_images Loads images when they become visible in the client viewport. before after
local_storage_cache Loads inlined CSS and image resources into HTML5 local storage whence the client fetches them subsequently rather than the server sending them again. before after
make_show_ads_async Converts synchronous Google AdSense tags to asynchronous format. before after
make_google_analytics_async Converts synchronous Google Analytics code to load asynchronously. before after
move_css_above_scripts Moves CSS Above Scripts. before after
move_css_to_head Moves CSS into the <head> element. before after
outline_css Moves large inline <style> tags into external files for cacheability. before after
outline_javascript Moves large inline <script> tags into external files for cacheability. before after
prioritize_critical_css Instruments the page, inlines its critical CSS at the top, and lazily loads the rest. before after
MapProxyDomain Proxies/optimizes trusted resources from domains not running PageSpeed. before after
remove_comments Removes HTML comments. before after
remove_quotes Removes unnecessary quotes in HTML tags. before after
resize_mobile_images Just like inline_preview_images, but uses smaller placeholder images for mobile browsers. before after
resize_rendered_image_dimensions Resize images to rendered dimensions. before after
responsive_images Serve responsive images using the srcset attribute. before after
rewrite_css Minifies CSS. before after
rewrite_css + extend_cache Cache extends images in CSS. before after
rewrite_css + rewrite_images Re-compress images in CSS. before after
rewrite_images Rescales, and compresses images; inlines small ones. before after
rewrite_javascript Minifies Javascript. before after
rewrite_style_attributes Rewrite the CSS in style attributes by applying the configured rewrite_css filter to it. before after
rewrite_style_attributes_with_url Rewrite the CSS in style attributes by applying the configured rewrite_css filter to it, but only if the attribute contains the text 'url('. before after
sprite_images Sprites images. before after
trim_urls Removes unnecessary prefixes from URLs. before after