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

Find a better way to inline CSS #1

Open
gajus opened this issue Jul 8, 2017 · 2 comments
Open

Find a better way to inline CSS #1

gajus opened this issue Jul 8, 2017 · 2 comments

Comments

@gajus
Copy link
Owner

gajus commented Jul 8, 2017

See notes:

https://github.com/gajus/usus/blob/3edef93496971e329024aa1856babcd4cc15f453/src/usus.js#L27-L40

@gajus
Copy link
Owner Author

gajus commented Jul 8, 2017

Related: c1d4f39

@paulpflug
Copy link

Nice tool your created.
I would advise to do the inlining in the end in node with cheerio, which you already depend on..

  const rootOuterHTML = (await DOM.getOuterHTML({
    nodeId: rootDocument.root.nodeId
  })).outerHTML;

  await end();
  $ = cheerio.load(rootOuterHTML)
  $("head").append("<style>....")
  return $.html()

you will have the cost of one additional html parsing, but the code will be much cleaner..

or even easier a quick and dirty string replace..

  return rootOuterHTML.replace("</head>","<style>...</head>")

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

No branches or pull requests

2 participants