GithubHelp home page GithubHelp logo

hartl3y94 / astro-critters Goto Github PK

View Code? Open in Web Editor NEW

This project forked from astro-community/astrocritters

0.0 0.0 0.0 30 KB

๐Ÿฆ” AstroJS GoogleChromeLabs critters integration. Inline your critical CSS with Astro.

License: Other

TypeScript 100.00%

astro-critters's Introduction

astro-critters ๐Ÿฆ”

This Astro integration brings critters to your Astro project.

Critters is a plugin that inlines your app's critical CSS and lazy-loads the rest.

Installation

There are two ways to add integrations to your project. Let's try the most convenient option first!

(experimental) astro add command

Astro includes a CLI tool for adding first party integrations: astro add. This command will:

  1. (Optionally) Install all necessary dependencies and peer dependencies
  2. (Also optionally) Update your astro.config.* file to apply this integration

To install astro-critters, run the following from your project directory and follow the prompts:

# Using NPM
npx astro add astro-critters
# Using Yarn
yarn astro add astro-critters
# Using PNPM
pnpx astro add astro-critters

Install dependencies manually

First, install the astro-critters integration like so:

npm install astro-critters

Then, apply this integration to your astro.config.* file using the integrations property:

astro.config.mjs

import { defineConfig } from "astro/config";
import critters from "astro-critters";

export default defineConfig({
	// ...
	integrations: [critters()],
});

Getting started

Critters should now automatically inline the critical CSS of your HTML files.

You can override any of the default options from the configuration at https://github.com/GoogleChromeLabs/critters#properties. Path is "./dist/" by default as in the Astro configuration.

export interface Options {
	path?: string;
	publicPath?: string;
	external?: boolean;
	inlineThreshold?: number;
	minimumExternalSize?: number;
	pruneSource?: boolean;
	mergeStylesheets?: boolean;
	additionalStylesheets?: string[];
	preload?: "body" | "media" | "swap" | "js" | "js-lazy";
	noscriptFallback?: boolean;
	inlineFonts?: boolean;
	preloadFonts?: boolean;
	fonts?: boolean;
	keyframes?: string;
	compress?: boolean;
	logLevel?: "info" | "warn" | "error" | "trace" | "debug" | "silent";
	reduceInlineStyles?: boolean;
	logger?: Logger;
}

Head to critters for all options and features available. You can also check the Astro Integration Documentation for more on integrations.

astro-critters's People

Contributors

nikolarhristov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.