Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for link preload hrefs #142

Closed
wants to merge 3 commits into from

Conversation

akrawchyk
Copy link

@akrawchyk akrawchyk commented Jun 15, 2016

This PR adds support for rel="preload" stylesheet links as specified here https://w3c.github.io/preload/.

It's useful for implementing the preload pattern with loadCSS.

@akrawchyk
Copy link
Author

akrawchyk commented Jun 15, 2016

Note, this depends on addyosmani/oust#19. I've updated the package.json with the repo for the changes to the oust package as an example.

@akrawchyk
Copy link
Author

akrawchyk commented Jun 15, 2016

These tests fail with the current master on node v6.2.1 branch as well:

  1. CLI acceptance should work well with the critical CSS file passed as an option
  2. CLI acceptance should work well with the critical CSS file piped to critical
  3. CLI acceptance (remote) should generate critical path css from external resource

Seems to be related to nodejs/node#3389 since the data returned from the call to execFile is a Buffer.

@akrawchyk
Copy link
Author

I believe this is the issue causing failing tests nodejs/node#6666.

Seems from https://github.com/nodejs/node/blob/357f904169c39bbc9c2d8558bbffce2337c83c1b/lib/child_process.js#L153 the buffer is not recognized as the expected encoding.

To workaround, I've casted the output from stdout as strings. If the output is already a string, it will remain a string, but if it's a buffer, it'll be converted to a string.

@@ -43,7 +43,7 @@
"meow": "^3.3.0",
"mime-types": "^2.1.6",
"object-assign": "^4.0.1",
"oust": "^0.2.3",
"oust": "git://github.com/akrawchyk/oust",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you reset this? oust 0.3.0 is now out with the PR you submitted.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm wondering if #129 is a better idea. I'm pleased oust supports preload links, but I noticed inline-critical automates the preload pattern.

This still might be useful, however, if there are manually added preload links in the HTML that critical will parse. Perhaps both PR's make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants