{"id":21700131,"url":"https://github.com/wp-digital/wp-critical-css-aws-lambda","last_synced_at":"2025-08-21T17:22:50.618Z","repository":{"id":56991698,"uuid":"101975182","full_name":"wp-digital/wp-critical-css-aws-lambda","owner":"wp-digital","description":"Generates critical stylesheets for templates via AWS Lambda","archived":false,"fork":false,"pushed_at":"2022-06-18T16:58:18.000Z","size":60,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-05T01:32:53.025Z","etag":null,"topics":["aws-lambda","critical-css","wordpress","wordpress-plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wp-digital.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-31T07:57:19.000Z","updated_at":"2024-05-26T00:23:04.000Z","dependencies_parsed_at":"2022-08-21T12:20:51.547Z","dependency_job_id":null,"html_url":"https://github.com/wp-digital/wp-critical-css-aws-lambda","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-digital%2Fwp-critical-css-aws-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-digital%2Fwp-critical-css-aws-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-digital%2Fwp-critical-css-aws-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-digital%2Fwp-critical-css-aws-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wp-digital","download_url":"https://codeload.github.com/wp-digital/wp-critical-css-aws-lambda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248573460,"owners_count":21126837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","critical-css","wordpress","wordpress-plugin"],"created_at":"2024-11-25T20:12:58.878Z","updated_at":"2025-04-12T13:34:04.878Z","avatar_url":"https://github.com/wp-digital.png","language":"PHP","readme":"# AWS Lambda Critical CSS\n\n### Description\n\nGenerates critical stylesheets for templates via AWS Lambda.\nSee also [AWS Lambda Critical CSS](https://github.com/innocode-digital/aws-lambda-critical-css).\n\n### Install\n\n- Preferable way is to use [Composer](https://getcomposer.org/):\n\n    ````\n    composer require innocode-digital/wp-critical-css-aws-lambda\n    ````\n\n  By default, it will be installed as [Must Use Plugin](https://codex.wordpress.org/Must_Use_Plugins).\n  It's possible to control with `extra.installer-paths` in `composer.json`.\n\n- Alternate way is to clone this repo to `wp-content/mu-plugins/` or `wp-content/plugins/`:\n\n    ````\n    cd wp-content/plugins/\n    git clone git@github.com:innocode-digital/wp-critical-css-aws-lambda.git\n    cd wp-critical-css-aws-lambda/\n    composer install\n    ````\n\nIf plugin was installed as regular plugin then activate **AWS Lambda Critical CSS** from Plugins page\nor [WP-CLI](https://make.wordpress.org/cli/handbook/): `wp plugin activate wp-critical-css-aws-lambda`.\n\n### Usage\n\nAdd the following constants to `wp-config.php`:\n\n````\ndefine( 'AWS_LAMBDA_CRITICAL_CSS_KEY', '' );\ndefine( 'AWS_LAMBDA_CRITICAL_CSS_SECRET', '' );\ndefine( 'AWS_LAMBDA_CRITICAL_CSS_REGION', '' ); // e.g. eu-west-1\n\ndefine( 'AWS_LAMBDA_CRITICAL_CSS_FUNCTION', '' ); // Optional, default value is \"critical-css-production-processor\"\n````\n\nCreate serverless function on your favorite service. Expected default name is **critical-css-production-processor**,\nbut you may use any other. There is a prepared function [AWS Lambda Critical CSS](https://github.com/innocode-digital/aws-lambda-critical-css).\n\n### Usage\n\nTo generate critical CSS from enqueued styles:\n\n````\nadd_filter( 'innocode_critical_css_styles', function () {\n    return [\n        // List of enqueued styles. \n        // Specify styles which you think are needed for critical CSS.\n    ];\n} );\n````\n\n### Caveats\n\n- Relative paths to custom fonts or images in stylesheets should be changed to absolute:\n\n````\nadd_filter( 'innocode_critical_css_stylesheet', function ( $stylesheet ) {\n    $stylesheet = str_replace(\n        '../fonts/',\n        get_template_directory_uri() . '/path/to/fonts/',\n        $stylesheet\n    );\n    $stylesheet = str_replace(\n        '../images/',\n        get_template_directory_uri() . '/path/to/images/',\n        $stylesheet\n    );\n\n    return $stylesheet;\n} );\n````\n\n- This plugin is only for generating and rendering critical CSS,\n  to defer CSS files you may use [Deferred loading](https://github.com/innocode-digital/wp-deferred-loading).\n\n- If page caching is used then you may want to add variable value from cookie in cache key. E.g. for Batcache it's\npossible to do with next code before `advanced-cache.php` file is included:\n\n````\nforeach ( array_keys( $_COOKIE ) as $name ) {\n    if ( strpos( $name, 'innocode_critical_css_' ) === 0 ) {\n        $GLOBALS['batcache']['unique']['innocode_critical_css'] = substr( $name, strlen( 'innocode_critical_css_' ) );\n    }\n}\n````\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-digital%2Fwp-critical-css-aws-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwp-digital%2Fwp-critical-css-aws-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-digital%2Fwp-critical-css-aws-lambda/lists"}