Git Product home page Git Product logo

netlify-plugin-inline-critical-css's Introduction

netlify-plugin-inline-critical-css

A Netlify Build plugin to extract and inline your critical CSS, built on top of the critical package. It extracts the CSS for above-the-fold content and inlines it into the HTML document in order to render content to the user as fast as possible.

Inlining the critical CSS directly into the HTML document eliminates additional requests and can be used to deliver a “one roundtrip” critical path where only the HTML is a blocking resource. You can use this plugin together with netlify-plugin-inline-source to inline your other assets/sources such as small images, SVGs or render-blocking scripts.

Usage and inputs

To install the plugin in the Netlify UI, use this direct in-app installation link or go to the Plugins directory.

For file-based installation, add it to your netlify.toml file.

[[plugins]]
  package = "netlify-plugin-inline-critical-css"

  # All inputs are optional, so you can omit this section.
  # Defaults are shown below.
  [plugins.inputs]
    # A filter used to target specific files in the publish directory. Be sure to only target HTML files. This option is passed onto the readdirp library, see https://github.com/paulmillr/readdirp#options for more info.
    fileFilter = ["*.html"]

    # A filter used to target or ignore specific directories in the publish directory. This option is passed onto the readdirp library, see https://github.com/paulmillr/readdirp#options for more info.
    directoryFilter = ["!node_modules"]

    # You can refer to `critical`’s documentation: https://github.com/addyosmani/critical for all options below.
    # Whether to remove the inlined styles from any stylesheet referenced in the HTML. Use with caution. Removing the critical CSS per page results in a unique async loaded CSS file for every page, meaning you can’t rely on cache across multiple pages.
    extract = false

    # An array of objects containing `width` and `height` properties to deliver critical CSS for multiple screen resolutions.
    dimensions = [
      { width = 414, height = 896 },
      { width = 1920, height = 1080 }
    ]

To complete file-based installation, from your project’s base directory, use npm, yarn, or any other Node.js package manager to add the plugin to devDependencies in package.json.

npm install -D netlify-plugin-inline-critical-css

Once installed and configured, the plugin will automatically run for all of your site’s deploys.

Testing locally

To test this plugin locally, you can use the Netlify CLI:

# Install the Netlify CLI.
npm install netlify-cli -g

# In the project working directory, run the build as Netlify would with the build bot.
netlify build

netlify-plugin-inline-critical-css's People

Contributors

rstavchansky avatar tom-bonnike avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

netlify-plugin-inline-critical-css's Issues

Debugging help - file not found style.css, but not referenced in my site

hey Tom, thanks for helping me out yesterday.. I'm running into another issue:

7:06:01 AM: ────────────────────────────────────────────────────────────────
7:06:01 AM:   Plugin "netlify-plugin-inline-critical-css" failed            
7:06:01 AM: ────────────────────────────────────────────────────────────────
7:06:01 AM: ​
7:06:01 AM:   Error message
7:06:01 AM:   Error: Failed to inline critical CSS.
7:06:01 AM:   Error: File not found: style.css
7:06:01 AM:          Current working directory: /opt/build/repo
7:06:01 AM:          Searched in: /opt/build/repo, /opt/build/repo/static/font/Inter

I've tried running the command locally, but not sure where to begin debugging it! I do not have any files called "style.css".

The site I'm trying to build is https://github.com/Riverside-Healthcare/Atlas-Website/tree/netlify

In Netlify I have your plugin installed, but for testing locally I just added your sample netlify.toml from the read me.

If you have any tips to point me in the right direction I'd appreciate it!

"unknown rule" with prism.css

Hi, When trying to run on prism.css I get an error:

────────────────────────────────────────────────────────────────
11:03:59 AM:   Plugin "netlify-plugin-inline-critical-css" failed            
11:03:59 AM: ────────────────────────────────────────────────────────────────
11:03:59 AM: ​
11:03:59 AM:   Error message
11:03:59 AM:   CssSyntaxError: Failed to inline critical CSS.
11:03:59 AM:   /static/lib/prism/prism.min.css:1:1828: Unknown word

Here's a link to the file it crashed on:

https://60a3d07b77d0cc000701018c--gallant-ptolemy-d1eb76.netlify.app/static/lib/prism/prism.min.css

Not all pages get inline critical css

Hi!

I have noticed something and would like to see if I'm missing something. When I deploy a website on netlify, files are on gitlab:

  • homepage, /index.html does get the inline critical css
  • blog, /blog/some-post/index.html does NOT get the inline css
    both have css link before </body>

If I move the css link before </head> in case of the blog folder then I get the inline critical css

I like having css file before </body> since, well it shoots the purpose of inline critical css if immidiatly afterwards the whole css is executed.

Anyhow, regardless, thank you for this plugin. A real time saver ;-)

Feature: Stylesheet optimization ruins CSS inlining

Hi,
Inline-critical was working perfectly.
So I decided to defer CSS loading with the trick
<link rel=stylesheet href=style.min.css media=print onload="this.media='all'"

But this ruins Critical CSS building. Seems like plugin doesn't find the stylesheet, and because CSS loading is defered all performances are ruined.

Thanks for your help

`Failed to launch chrome` error

The following error is happening in some builds:

Failed to inline critical CSS.
Failed to launch chrome!
Inconsistency detected by ld.so: dl-tls.c: 493: _dl_allocate_tls_init: Assertion `listp->slotinfo[cnt].gen <= GL(dl_tls_generation)' failed!


TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
 
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/Launcher.js:342:14 onClose
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/Launcher.js:332:60 ChildProcess.<anonymous>
    events.js:322:22 ChildProcess.emit
    internal/child_process.js:275:12 Process.ChildProcess._handle.onexit

The repository is here. The build logs do not contain any additional information unfortunately.
Do you know what the error might be?

Lingering puppeteer processes cause penthouse to timeout and build to fail

Awesome plugin!
It was working fine until it starting causing problems for my builds.

I'm unclear how this happened or how to resolve it, but I'm currently in a situation where my builds fail because of lingering puppeteer processes.
I can remove the plugin and proceed, but there's something up with this plugin causing puppeteer to linger in certain cases.

Here's what is shown at the end of the build.

2:17:19 AM: ** WARNING **
2:17:19 AM: There are some lingering processes even after the build process finished:
2:17:19 AM: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
2:17:19 AM: buildbot 1548 0.1 0.1 447788 48476 ? S 06:16 0:00 /opt/build/repo/node_modules/netlify-plugin-inline-critical-css/node_modules/puppeteer/.local-chromium/linux-650583/chrome-linux/chrome --type=zygote --no-sandbox --headless --headless
2:17:19 AM: buildbot 1561 0.6 0.3 555216 96252 ? Sl 06:16 0:00 /opt/build/repo/node_modules/netlify-plugin-inline-critical-css/node_modules/puppeteer/.local-chromium/linux-650583/chrome-linux/chrome --type=gpu-process --field-trial-handle=4489240811974593649,7639743241185319030,131072 --enable-features=NetworkService,NetworkServiceInProcess --disable-features=BlinkGenPropertyTrees,TranslateUI,site-per-process --no-sandbox --disable-breakpad --headless --headless --gpu-preferences=KAAAAAAAAAAgAAAgAQAAAAAAAAAAAGAAAAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAA --use-gl=swiftshader-webgl --override-use-software-gl-for-tests --service-request-channel-token=1495995070197870940
2:17:19 AM: Our builds do not kill your processes automatically, so please make sure
2:17:19 AM: that nothing is running after your build finishes, or it will be marked as
2:17:19 AM: failed since something is still running.

And the particular log as it relates to this great plugin:

2:17:07 AM: ┌────────────────────────────────────────────────────┐
2:17:07 AM: │ Plugin "netlify-plugin-inline-critical-css" failed │
2:17:07 AM: └────────────────────────────────────────────────────┘
2:17:07 AM: ​
2:17:07 AM: Error message
2:17:07 AM: Error: Failed to inline critical CSS.
2:17:07 AM: Penthouse timed out after 30s.
2:17:07 AM: ​
2:17:07 AM: Plugin details
2:17:07 AM: Package: netlify-plugin-inline-critical-css
2:17:07 AM: Version: 1.0.4
2:17:07 AM: Repository: git+https://github.com/Tom-Bonnike/netlify-plugin-inline-critical-css.git
2:17:07 AM: npm link: https://www.npmjs.com/package/netlify-plugin-inline-critical-css
2:17:07 AM: Report issues: https://github.com/Tom-Bonnike/netlify-plugin-inline-critical-css/issues
2:17:07 AM: ​
2:17:07 AM: Error location
2:17:07 AM: In "onPostBuild" event in "netlify-plugin-inline-critical-css" from netlify.toml and package.json
2:17:07 AM: at Timeout.setTimeout (/node_modules/netlify-plugin-inline-critical-css/node_modules/penthouse/lib/core.js:341:16)
2:17:07 AM: ​
2:17:07 AM: Resolved config
2:17:07 AM: build:
2:17:07 AM: command: 'npm-run-all build:css build:js build:html'
2:17:07 AM: environment:
2:17:07 AM: functions: /opt/build/repo/functions
2:17:07 AM: publish: /opt/build/repo/_11ty_output
2:17:07 AM: plugins:
2:17:07 AM: - inputs:
2:17:07 AM: buildDir: _11ty_output
2:17:07 AM: origin: config
2:17:07 AM: package: '@netlify/plugin-sitemap'
2:17:07 AM: - origin: config
2:17:07 AM: package: netlify-plugin-search-index
2:17:07 AM: - inputs:
2:17:07 AM: dimensions:
2:17:07 AM: - height: 480
2:17:07 AM: width: 320
2:17:07 AM: - height: 896
2:17:07 AM: width: 414
2:17:07 AM: - height: 1080
2:17:07 AM: width: 1920
2:17:07 AM: extract: false
2:17:07 AM: minify: true
2:17:07 AM: origin: config
2:17:07 AM: package: netlify-plugin-inline-critical-css
2:17:07 AM: - inputs:
2:17:07 AM: checkPaths:
2:17:07 AM: - /
2:17:07 AM: - /articles/
2:17:07 AM: - /cleaning-your-mask/
2:17:07 AM: resultMode: warn
2:17:07 AM: origin: config
2:17:07 AM: package: netlify-plugin-a11y

Do you know of a way to kill the puppeteer process in Netlify?

Parallelize execution directly via `critical`

This plugin currently runs on multiple files sequentially, which can potentially be very slow. critical is apparently looking at allowing multiple sources to be passed, we should use that when it’ll be possible:

I tried running it in parallel with a promise pool but this led to out of memory errors (could maybe have been fixed by reducing the concurrency) and lingering Puppeteer processes (still TBD if that was the cause).

SyntaxError: 'noscript)>[rel="stylesheet"]' is not a valid selector

Not sure where to start in debugging this. Is there anything else I can provide here?
Thanks

2. netlify-plugin-inline-critical-css (onPostBuild event)     
4:23:30 PM: ────────────────────────────────────────────────────────────────
4:23:30 PM: ​
4:23:31 PM: ​
4:23:31 PM:   Plugin "netlify-plugin-inline-critical-css" failed            
4:23:31 PM: ────────────────────────────────────────────────────────────────
4:23:31 PM: ​
4:23:31 PM:   Error message
4:23:31 PM:   SyntaxError: 'noscript)>[rel="stylesheet"]' is not a valid selector
4:23:31 PM: ​
4:23:31 PM:   Plugin details
4:23:31 PM:   Package:        netlify-plugin-inline-critical-css
4:23:31 PM:   Version:        2.0.0
4:23:31 PM:   Repository:     git+https://github.com/Tom-Bonnike/netlify-plugin-inline-critical-css.git
4:23:31 PM:   npm link:       https://www.npmjs.com/package/netlify-plugin-inline-critical-css
4:23:31 PM:   Report issues:  https://github.com/Tom-Bonnike/netlify-plugin-inline-critical-css/issues
4:23:31 PM: ​
4:23:31 PM:   Error location
4:23:31 PM:   In "onPostBuild" event in "netlify-plugin-inline-critical-css" from Netlify app

Resolve it's own dependencies

To test Netlify plugins I add them manually via the UI. With this plugin I had a very log build, then a failure because npm or yarn wasn't installed. I would suggest that, if possible, this plugin check its environment first then resolve any missing dependencies.

If you're not able to do that due to something at Netlify, I will happily bark up their tree.

Thank you for the work on this.

Plugin error not telling me where the error was

I know the error has something to do with my css but, i don't know where.

────────────────────────────────────────────────────────────────
  Plugin "netlify-plugin-inline-critical-css" failed
────────────────────────────────────────────────────────────────
​
  Error message
  CssSyntaxError: Failed to inline critical CSS.
  <css input>:1:1971: Missed semicolon
​
  Plugin details
  Package:        netlify-plugin-inline-critical-css
  Version:        1.2.0
  Repository:     git+https://github.com/Tom-Bonnike/netlify-plugin-inline-critical-css.git
  npm link:       https://www.npmjs.com/package/netlify-plugin-inline-critical-css
  Report issues:  https://github.com/Tom-Bonnike/netlify-plugin-inline-critical-css/issues
​
  Error location
  In "onPostBuild" event in "netlify-plugin-inline-critical-css" from Netlify app
      at Input.error (/.netlify/plugins/node_modules/postcss/lib/input.js:128:16)
      at Parser.checkMissedSemicolon (/.netlify/plugins/node_modules/postcss/lib/parser.js:601:22)
      at Parser.decl (/.netlify/plugins/node_modules/postcss/lib/parser.js:284:46)
      at Parser.other (/.netlify/plugins/node_modules/postcss/lib/parser.js:164:12)
      at Parser.parse (/.netlify/plugins/node_modules/postcss/lib/parser.js:75:16)
      at Function.parse (/.netlify/plugins/node_modules/postcss/lib/parse.js:17:12)
      at getCssMapping (/.netlify/plugins/node_modules/postcss-discard/index.js:88:19)
      at /.netlify/plugins/node_modules/postcss-discard/index.js:169:21
      at creator (/.netlify/plugins/node_modules/postcss/lib/postcss.js:133:35)
      at extractCss (/.netlify/plugins/node_modules/inline-critical/src/css.js:42:20)
​

Site is first showing content without css

Hi,

I'm using this plugin i a gridsome site.
The plugin works fine but when i first enter the website it is showing content without css and after 2, 3 seconds i got the css styles back.

Error `Cannot read property 'clear' of undefined`

The following error happens in some builds:

Failed to inline critical CSS.
Evaluation failed: TypeError: Cannot read property 'clear' of undefined
    at isElementAboveFold (__puppeteer_evaluation_script__:20:44)
    at isSelectorCritical (__puppeteer_evaluation_script__:62:11)
    at Array.filter (<anonymous>)
    at filterSelectors (__puppeteer_evaluation_script__:72:27)
    at pruneNonCriticalSelectors (__puppeteer_evaluation_script__:77:10) 
    __puppeteer_evaluation_script__:20:44 isElementAboveFold
    __puppeteer_evaluation_script__:62:11 isSelectorCritical
    __puppeteer_evaluation_script__:72:27 filterSelectors
    __puppeteer_evaluation_script__:77:10 pruneNonCriticalSelectors
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/ExecutionContext.js:121:13 ExecutionContext.evaluateHandle
    internal/process/task_queues.js:97:5 processTicksAndRejections
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/ExecutionContext.js:48:20 async ExecutionContext.evaluate
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/lib/core.js:461:27 async
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/helper.js:110:27 ExecutionContext.<anonymous>
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/ExecutionContext.js:48:31 ExecutionContext.evaluate
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/helper.js:111:23 ExecutionContext.<anonymous>
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/DOMWorld.js:112:20 DOMWorld.evaluate
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/helper.js:110:27 Frame.<anonymous>
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/Page.js:782:43 Page.evaluate
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/node_modules/puppeteer/lib/helper.js:111:23 Page.<anonymous>
    /opt/buildhome/.netlify-build-plugins/node_modules/penthouse/lib/core.js:461:38 

Do you know what the problem might be?

`ENOENT` error when deleting a file

The following error is happening is several builds:

Error: ENOENT: no such file or directory, unlink '/tmp/3723555fb8e4f6ee3ed2809c8ef4a685/css/styles.css' 

There is no stack trace unfortunately.

The full build logs:

4:21:29 PM: Build ready to start
4:21:31 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
4:21:31 PM: build-image tag: v3.4.1
4:21:31 PM: buildbot version: fcbc7a79f7372e5995cf02954ef19fc48d20c871
4:21:31 PM: Fetching cached dependencies
4:21:32 PM: Starting to download cache of 12.1MB
4:21:32 PM: Finished downloading cache in 358.896451ms
4:21:32 PM: Starting to extract cache
4:21:32 PM: Finished extracting cache in 159.688483ms
4:21:32 PM: Finished fetching cache in 522.807772ms
4:21:32 PM: Starting to prepare the repo for build
4:21:32 PM: Preparing Git Reference refs/heads/master
4:21:34 PM: Starting build script
4:21:34 PM: Installing dependencies
4:21:34 PM: Python version set to 2.7
4:21:35 PM: Downloading and installing node v10.22.0...
4:21:35 PM: Downloading https://nodejs.org/dist/v10.22.0/node-v10.22.0-linux-x64.tar.xz...
4:21:36 PM: Computing checksum with sha256sum
4:21:36 PM: Checksums matched!
4:21:38 PM: Now using node v10.22.0 (npm v6.14.6)
4:21:38 PM: Started restoring cached build plugins
4:21:38 PM: Finished restoring cached build plugins
4:21:38 PM: Attempting ruby version 2.6.2, read from environment
4:21:40 PM: Using ruby version 2.6.2
4:21:40 PM: Using PHP version 5.6
4:21:40 PM: 5.2 is already installed.
4:21:40 PM: Using Swift version 5.2
4:21:40 PM: Started restoring cached go cache
4:21:40 PM: Finished restoring cached go cache
4:21:40 PM: Installing Go version 1.12
4:21:46 PM: unset GOOS;
4:21:46 PM: unset GOARCH;
4:21:46 PM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64';
4:21:46 PM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64/bin:${PATH}";
4:21:46 PM: go version >&2;
4:21:46 PM: export GIMME_ENV="/opt/buildhome/.gimme_cache/env/go1.12.linux.amd64.env"
4:21:46 PM: go version go1.12 linux/amd64
4:21:46 PM: Installing missing commands
4:21:46 PM: Verify run directory
4:21:47 PM: ​
4:21:47 PM: ┌─────────────────────────────┐
4:21:47 PM: │        Netlify Build        │
4:21:47 PM: └─────────────────────────────┘
4:21:47 PM: ​
4:21:47 PM: ❯ Version
4:21:47 PM:   @netlify/build 3.3.0
4:21:47 PM: ​
4:21:47 PM: ❯ Flags
4:21:47 PM:   deployId: 5f50fbe9b549c60008b23ff9
4:21:47 PM:   mode: buildbot
4:21:47 PM: ​
4:21:47 PM: ❯ Current directory
4:21:47 PM:   /opt/build/repo
4:21:47 PM: ​
4:21:47 PM: ❯ Config file
4:21:47 PM:   /opt/build/repo/netlify.toml
4:21:47 PM: ​
4:21:47 PM: ❯ Context
4:21:47 PM:   production
4:21:47 PM: ​
4:21:47 PM: ❯ Loading plugins
4:21:47 PM:    - [email protected] from netlify.toml
4:21:47 PM:    - [email protected] from netlify.toml
4:21:55 PM: ​
4:21:55 PM: ┌────────────────────────────────────────────────────────┐
4:21:55 PM: │ 1. onPostBuild command from netlify-plugin-image-optim │
4:21:55 PM: └────────────────────────────────────────────────────────┘
4:21:55 PM: ​
4:21:58 PM: │ File                                    │ Before    │ After     │ Reduction │
4:21:58 PM: ├─────────────────────────────────────────┼───────────┼───────────┼───────────┤
4:21:58 PM: │ /assets/img/builder.jpeg                │ 196.29 KB │ 196.29 KB │ 0 B       │
4:21:58 PM: │ /assets/img/buildersm.jpg               │ 41.06 KB  │ 41.06 KB  │ 0 B       │
4:21:58 PM: │ /assets/img/close-icon.svg              │ 333 B     │ 215 B     │ 118 B     │
4:21:58 PM: │ /assets/img/digital-marketing.png       │ 49.6 KB   │ 16.63 KB  │ 32.97 KB  │
4:21:58 PM: │ /assets/img/kitwe-marketing-bg.jpeg     │ 49.79 KB  │ 49.79 KB  │ 0 B       │
4:21:58 PM: │ /assets/img/kitwe-marketing-bgs.jpg     │ 10.78 KB  │ 10.78 KB  │ 0 B       │
4:21:58 PM: │ /assets/img/marketing.jpg               │ 513.78 KB │ 513.78 KB │ 0 B       │
4:21:58 PM: │ /assets/img/responsive.png              │ 113.71 KB │ 38.7 KB   │ 75 KB     │
4:21:58 PM: │ /assets/img/web-design4.jpeg            │ 172.1 KB  │ 172.1 KB  │ 0 B       │
4:21:58 PM: │ /assets/img/web-design4.jpg             │ 219.67 KB │ 219.67 KB │ 0 B       │
4:21:58 PM: │ /assets/img/web-design4s.jpg            │ 33.5 KB   │ 33.5 KB   │ 0 B       │
4:21:58 PM: │ /assets/img/web-designer-large.jpeg     │ 240.91 KB │ 240.91 KB │ 0 B       │
4:21:58 PM: │ /assets/img/web-designer-small.jpg      │ 43.26 KB  │ 43.26 KB  │ 0 B       │
4:21:58 PM: │ /assets/img/wood1.jpeg                  │ 353.81 KB │ 353.81 KB │ 0 B       │
4:21:58 PM: │ /assets/img/zambia-1.png                │ 1.64 KB   │ 844 B     │ 835 B     │
4:21:58 PM: │ /assets/img/zambia-2.png                │ 2.74 KB   │ 1.75 KB   │ 1006 B    │
4:21:58 PM: │ /assets/img/zambia-3.png                │ 3.67 KB   │ 1.59 KB   │ 2.07 KB   │
4:21:58 PM: │ /assets/img/zambiaflag.png              │ 1.8 KB    │ 1.8 KB    │ 0 B       │
4:21:58 PM: │ /assets/img/portfolio/design-finish.jpg │ 10.26 KB  │ 10.26 KB  │ 0 B       │
4:21:58 PM: │ /assets/img/portfolio/price-website.jpg │ 15.96 KB  │ 15.96 KB  │ 0 B       │
4:21:58 PM: │ /assets/img/portfolio/web-design3.jpg   │ 28.08 KB  │ 28.08 KB  │ 0 B       │
4:21:58 PM: ┌────────────────────────────────────────┐
4:21:58 PM: │   Images optimized - 111.96 KB saved   │
4:21:58 PM: └────────────────────────────────────────┘
4:21:58 PM: ​
4:21:58 PM: (netlify-plugin-image-optim onPostBuild completed in 2.8s)
4:21:58 PM: ​
4:21:58 PM: ┌────────────────────────────────────────────────────────────────┐
4:21:58 PM: │ 2. onPostBuild command from netlify-plugin-inline-critical-css │
4:21:58 PM: └────────────────────────────────────────────────────────────────┘
4:21:58 PM: ​
4:22:06 PM: ​
4:22:06 PM: ┌────────────────────────────────────────────────────────────┐
4:22:06 PM: │ Plugin "netlify-plugin-inline-critical-css" internal error │
4:22:06 PM: └────────────────────────────────────────────────────────────┘
4:22:06 PM: ​
4:22:06 PM:   Error message
4:22:06 PM:   UnhandledRejection: a promise was rejected but not handled: Error: ENOENT: no such file or directory, unlink '/tmp/3723555fb8e4f6ee3ed2809c8ef4a685/css/styles.css'
4:22:06 PM:   Error: ENOENT: no such file or directory, unlink '/tmp/3723555fb8e4f6ee3ed2809c8ef4a685/css/styles.css'
4:22:06 PM: ​
4:22:06 PM:   Plugin details
4:22:06 PM:   Package:        netlify-plugin-inline-critical-css
4:22:06 PM:   Version:        1.1.3
4:22:06 PM:   Repository:     git+https://github.com/Tom-Bonnike/netlify-plugin-inline-critical-css.git
4:22:06 PM:   npm link:       https://www.npmjs.com/package/netlify-plugin-inline-critical-css
4:22:06 PM:   Report issues:  https://github.com/Tom-Bonnike/netlify-plugin-inline-critical-css/issues
4:22:06 PM: ​
4:22:06 PM:   Error location
4:22:06 PM:   In "onPostBuild" event in "netlify-plugin-inline-critical-css" from netlify.toml
4:22:06 PM: ​
4:22:06 PM:   Error properties
4:22:06 PM:   {
4:22:06 PM:     errno: -2,
4:22:06 PM:     code: 'ENOENT',
4:22:06 PM:     syscall: 'unlink',
4:22:06 PM:     path: '/tmp/3723555fb8e4f6ee3ed2809c8ef4a685/css/styles.css'
4:22:06 PM:   }
4:22:06 PM: ​
4:22:06 PM:   Resolved config
4:22:06 PM:   plugins:
4:22:06 PM:     - inputs: {}
4:22:06 PM:       origin: config
4:22:06 PM:       package: netlify-plugin-image-optim
4:22:06 PM:     - inputs:
4:22:06 PM:         extract: false
4:22:06 PM:         minify: true
4:22:06 PM:       origin: config
4:22:06 PM:       package: netlify-plugin-inline-critical-css
4:22:06 PM: Caching artifacts
4:22:06 PM: Started saving build plugins
4:22:06 PM: Finished saving build plugins
4:22:06 PM: Started saving pip cache
4:22:06 PM: Finished saving pip cache
4:22:06 PM: Started saving emacs cask dependencies
4:22:06 PM: Finished saving emacs cask dependencies
4:22:06 PM: Started saving maven dependencies
4:22:06 PM: Finished saving maven dependencies
4:22:06 PM: Started saving boot dependencies
4:22:06 PM: Finished saving boot dependencies
4:22:06 PM: Started saving go dependencies
4:22:08 PM: Finished saving go dependencies
4:22:11 PM: Error running command: Build script returned non-zero exit code: 1
4:22:11 PM: Failing build: Failed to build site
4:22:11 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
4:22:11 PM: Finished processing build request in 39.723799525s

The commit/repo is here.

Do you know what might be happening?

Plugin "netlify-plugin-inline-critical-css" failed: Failed to launch the browser process!

Hi,
sorry to be back.

Since March 28 my Netlify builds are tricky.
Having CriticalCSS build crashes, I reverted to Hugo 0.81.0.
Build command is the simplest: hugo
Critical config is the simplest

  [[plugins]]
  package = "netlify-plugin-inline-critical-css"

I checked all my files for HTML or script errors but all validators are green.

I still have these Netlify logs:

Plugin "netlify-plugin-inline-critical-css" failed

Error: Failed to inline critical CSS.
Failed to launch the browser process!
Inconsistency detected by ld.so: dl-tls.c: 493: _dl_allocate_tls_init: Assertion `listp->slotinfo[cnt].gen <= GL(dl_tls_generation)' failed!

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

In "onPostBuild" event in "netlify-plugin-inline-critical-css" from netlify.toml
at onClose (/.netlify/plugins/node_modules/puppeteer/lib/Launcher.js:750:14)

Don't you have this on your side ?
Thanks a lot,

JB

Error when loading the plugin

The following error happened 2 hours ago in a build:

Could not import plugin:
Unexpected token { 
    vm.js:80:10 createScript
    vm.js:139:10 Object.runInThisContext
    module.js:617:28 Module._compile
    module.js:664:10 Object.Module._extensions..js
    module.js:566:32 Module.load
    module.js:506:12 tryModuleLoad
    module.js:498:3 Function.Module._load
    module.js:597:17 Module.require
    internal/module.js:11:18 require
    /opt/build/repo/node_modules/fs-extra/lib/mkdirs/index.js:3:44 Object.<anonymous>

I am guessing this probably was triggered by you @Tom-Bonnike, but I just wanted to let you in case this was an unresolved bug. Thanks!

Error `Cannot read property 'walkDecls' of undefined`

The following error is happening in some builds:

@media (min-width:320px) and (max-width:480px){{padding-top:65px;overflow-x:hidden !important;height:100% !important;}}/*!sc*/
data-styled.g145[id="sc-global-jYygkk1"]{content:"sc-global-jYygkk1,"}/*!sc*/
<css input>:13:267730: Missed semicolon

┌────────────────────────────────────────────────────┐
│ Plugin "netlify-plugin-inline-critical-css" failed │
└────────────────────────────────────────────────────┘

Error message
TypeError: Failed to inline critical CSS.
Cannot read property 'walkDecls' of undefined 
    /opt/buildhome/.netlify-build-plugins/node_modules/postcss-discard/index.js:98:7 getCssMapping
    /opt/buildhome/.netlify-build-plugins/node_modules/postcss-discard/index.js:169:21 
    /opt/buildhome/.netlify-build-plugins/node_modules/postcss/lib/postcss.js:133:35 creator
    /opt/buildhome/.netlify-build-plugins/node_modules/inline-critical/src/css.js:42:20 extractCss
    /opt/buildhome/.netlify-build-plugins/node_modules/inline-critical/index.js:66:25 inline
    /opt/buildhome/.netlify-build-plugins/node_modules/critical/src/core.js:222:21 create
    internal/process/task_queues.js:97:5 processTicksAndRejections
    /opt/buildhome/.netlify-build-plugins/node_modules/critical/index.js:23:20 async generate

Do you know what the error might be?

EISDIR: illegal operation on a directory, read

Directories ending with *.html should be excluded from inlining, otherwise the following error makes the build fail:

Failed to inline critical CSS.
EISDIR: illegal operation on a directory, read 

Failing on page with large json schema

This is probably an issue with Critical or another underlying package but I have encountered this issue where there is a regex that is created with the whole content of the script tag for our schema.org schema (<script data-n-head="ssr" type="application/ld+json">).

Logs from the Netlify build script:

Invalid regular expression: /([^\S\r\n]*){"@context":"https://schema.org",
[...] 
: Regular expression too large

This is only happening when trying to upgrade from 1.2.0 to 2.0.0
Maybe you have an idea of the source of the issue?

Thanks

Out-of-memory error

Some builds are crashing due to running out of memory:

<--- Last few GCs --->
[15157:0x2872030] 70768 ms: Scavenge 1374.6 (1424.2) -> 1373.9 (1424.2) MB, 3.8 / 0.0 ms (average mu = 0.106, current mu = 0.032) allocation failure
[15157:0x2872030] 70778 ms: Scavenge 1374.8 (1424.2) -> 1374.0 (1424.2) MB, 3.8 / 0.0 ms (average mu = 0.106, current mu = 0.032) allocation failure
[15157:0x2872030] 70788 ms: Scavenge 1374.9 (1424.2) -> 1374.2 (1424.7) MB, 4.2 / 0.0 ms (average mu = 0.106, current mu = 0.032) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x2cd14995be1d]
1: StubFrame [pc: 0x2cd14994e6d6]
Security context: 0x036476b9e6c1 <JSObject>
2: replace [0x36476b905c1](this=0x21171492ca99 <String[20]: .qc-guide-box:before>,0x23a2b15d84a1 <JSRegExp <String[59]: :?:before|:?:after|:?:visited|:?:first-letter|:?:first-line>>,0x2fc6142029f1 <String[0]: >)
3: enter [0x3dafe7c7d1d9] [/opt/build/repo/node_modules/penthouse/lib/selectors-profile.js:~96] [pc=0x...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x8fb090 node::Abort() [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
2: 0x8fb0dc [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
3: 0xb031ce v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
4: 0xb03404 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
5: 0xef7462 [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
6: 0xef7568 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
7: 0xf03642 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
8: 0xf03f74 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
9: 0xf06be1 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
10: 0xed0064 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
11: 0x11701ee v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/opt/buildhome/.nvm/versions/node/v10.20.1/bin/node]
12: 0x2cd14995be1d

Do you know where this might come from?

`src and type required `

The following error is happening in some builds:

Failed to inline critical CSS.
`src` and `type` required 
    /opt/buildhome/.netlify-build-plugins/node_modules/oust/index.js:52:15 oust
    /opt/buildhome/.netlify-build-plugins/node_modules/oust/index.js:82:37 Function.module.exports.raw
    /opt/buildhome/.netlify-build-plugins/node_modules/critical/src/file.js:354:28 getStylesheetHrefs
    /opt/buildhome/.netlify-build-plugins/node_modules/critical/src/file.js:839:32 getDocument
    /opt/buildhome/.netlify-build-plugins/node_modules/critical/src/core.js:108:26 async create
    /opt/buildhome/.netlify-build-plugins/node_modules/critical/index.js:23:20 async Object.generate
    /opt/buildhome/.netlify-build-plugins/node_modules/netlify-plugin-inline-critical-css/index.js:28:9 async onPostBuild
    src/plugins/child/run.js:18:3 async Object.run
    src/plugins/child/main.js:38:38 async handleEvent
    src/plugins/ipc.js:97:9 async process.<anonymous>

The repository is private. The build logs do not contain any additional information unfortunately. Do you know what the problem might be?

Plugin removes inline JavaScript from <head>

When this plugin is activated in my build, it somehow removes inline JS from the <head> of my HTML files.

In the <head>, I have two Facebook pixel scripts, each with a different ID. The second one is erased, as though the plugin thinks it's duplicated CSS. It also erases part of the FB pixel code between a <noscript> tag, and the contents of another third-party <noscript> tag, so that both tags are left empty. I have tested this with Netlify deploys as well as the Netlify CLI local builds.

See examples below (actual IDs replaced with Xs and Ys):

Example of part of the file with the plugin not activated:

...
<script type=text/plain cookie-consent=tracking>
      !function(f,b,e,v,n,t,s)
      {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(arguments)};
      if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
      n.queue=[];t=b.createElement(e);t.async=!0;
      t.src=v;s=b.getElementsByTagName(e)[0];
      s.parentNode.insertBefore(t,s)}(window,document,'script',
      'https://connect.facebook.net/en_US/fbevents.js');
      fbq('init', 'XXXXXX');
      fbq('track', 'PageView');
    </script><noscript><img height=1 width=1 src="https://www.facebook.com/tr?id=XXXXXX&ev=PageView&noscript=1"></noscript><script type=text/plain cookie-consent=tracking>
      !function(f,b,e,v,n,t,s)
      {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(arguments)};
      if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
      n.queue=[];t=b.createElement(e);t.async=!0;
      t.src=v;s=b.getElementsByTagName(e)[0];
      s.parentNode.insertBefore(t,s)}(window,document,'script',
      'https://connect.facebook.net/en_US/fbevents.js');
      fbq('init', 'YYYYYY');
      fbq('track', 'PageView');
    </script><noscript><img height=1 width=1 src="https://www.facebook.com/tr?id=YYYYYY&ev=PageView&noscript=1"></noscript><noscript>ePrivacy and GPDR Cookie Consent by <a href=https://www.cookieconsent.com/ rel="nofollow noopener">Cookie Consent</a></noscript></head>
...

Example with the plugin activated:

...
<script type="text/plain" cookie-consent="tracking">
      !function(f,b,e,v,n,t,s)
      {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
      n.callMethod.apply(n,arguments):n.queue.push(arguments)};
      if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
      n.queue=[];t=b.createElement(e);t.async=!0;
      t.src=v;s=b.getElementsByTagName(e)[0];
      s.parentNode.insertBefore(t,s)}(window,document,'script',
      'https://connect.facebook.net/en_US/fbevents.js');
      fbq('init', 'XXXXXX');
      fbq('track', 'PageView');
    </script><noscript></noscript></head>
...

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.