惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

M
MIT News - Artificial intelligence
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
人人都是产品经理
人人都是产品经理
WordPress大学
WordPress大学
The Cloudflare Blog
IT之家
IT之家
雷峰网
雷峰网
小众软件
小众软件
博客园 - 叶小钗
博客园 - 聂微东
爱范儿
爱范儿
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
博客园 - 【当耐特】
V
V2EX
博客园_首页
T
Tailwind CSS Blog

The Eleventy Firehose

New Sponsorship Tiers for the Build Awesome Kickstarter Securely Publishing our Packages to npm Back Build Awesome Pro and make it easier to build for the web! The Possum Mascot, now with additional Awesome Build Awesome (11ty) (@11ty.dev) Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Build Awesome (11ty) (@11ty.dev) Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Build Awesome (11ty) (@11ty.dev) Release Import v1.0.20 · 11ty/import Release Import v1.0.21 · 11ty/import Build Awesome (11ty) (@11ty.dev) Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Build Awesome (11ty) (@11ty.dev) Cozy Keyboard Build and Build Awesome AMA Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Build Awesome (11ty) (@11ty.dev) A few demos of Editing and Collaboration in Build Awesome Pro (as always, AMA!) Build Awesome (11ty) (@11ty.dev) Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Bluesky: May 6, 2026 at 7:54:00 PM UTC An Awesome Theming Demo with Dave Gandy (and more Build Awesome AMA) Build Awesome (11ty) (@11ty@neighborhood.11ty.dev) Release v8.0.0 · 11ty/eleventy-plugin-vite Build Awesome Pro Kickstarter AMA
Quick Tip: Inline Minified CSS
Zach Leather · 2026-06-07 · via The Eleventy Firehose

Originally posted on The Simplest Web Site That Could Possibly Work Well on zachleat.com

This tip works well on small sites that don’t have a lot of CSS. Inlining your CSS removes an external request from your critical path and speeds up page rendering times! If your CSS file is small enough, this is a simplification/end-around for Critical CSS approaches.

Installation

npm install clean-css to make the CSS minifier available in your project.

Configuration

Add the following cssmin filter to your Eleventy Config file:

eleventy.config.js

import CleanCSS from "clean-css";

export default function (eleventyConfig) {
	eleventyConfig.addFilter("cssmin", function (code) {
		return new CleanCSS({}).minify(code).styles;
	});
};
const CleanCSS = require("clean-css");

module.exports = function (eleventyConfig) {
	eleventyConfig.addFilter("cssmin", function (code) {
		return new CleanCSS({}).minify(code).styles;
	});
};

Create your CSS File

Add a sample CSS file to your _includes directory. Let’s call it sample.css.

body {
	font-family: fantasy;
}

Capture and Minify

Capture the CSS into a variable and run it through the filter (this sample is using Nunjucks syntax)

<!-- capture the CSS content as a Nunjucks variable -->
{% set css %} {% include "sample.css" %} {% endset %}
<!-- feed it through our cssmin filter to minify -->
<style>
	{{ css | cssmin | safe }}
</style>

Warning about Content Security Policy

WARNING

If you are using a Content Security Policy on your website, make sure the style-src directive allows 'unsafe-inline'. Otherwise, your inline CSS will not load.

Or: use an 11ty.js Template

Contributed by Zach Green

You can also inline minified CSS in a JavaScript template. This technique does not use filters, and instead uses async functions:

eleventy.config.js

import fs from "node:fs/promises";
import path from "node:path";
import CleanCSS from "clean-css";

export default async function (data) {
	return `<style>
	  ${await fs
			.readFile(path.resolve(__dirname, "./sample.css"))
			.then((data) => new CleanCSS().minify(data).styles)}
	</style>`;
};
const fs = require("node:fs/promises");
const path = require("node:path");
const CleanCSS = require("clean-css");

module.exports = async function (data) {
	return `<style>
	  ${await fs
			.readFile(path.resolve(__dirname, "./sample.css"))
			.then((data) => new CleanCSS().minify(data).styles)}
	</style>`;
};