unified

Project:rehypejs/rehype-minify

Package:rehype-javascript-to-bottom@2.0.0

  1. Dependencies:2·Dependents:0
  2. rehype plugin to move JavaScript <script> to <body>
  1. unified 132
  2. hast 78
  3. rehype 74
  4. head 3
  5. js 2

rehype-javascript-to-bottom

Build Coverage Downloads Size Sponsors Backers Chat

Move JS <script> elements to the end of <body>.

This can decrease the time to first render.

You can pass filter, a function called with each checked node, returning true if the script should be moved, and false if not.

Install

npm:

npm install rehype-javascript-to-bottom

Example

In
<!doctype html><html><head><script src="index.js"></script></head><body></body></html>
Out
<!doctype html><html><head></head><body><script src="index.js"></script></body></html>

Contribute

See contributing.md in rehypejs/.github for ways to get started. See support.md for ways to get help.

This project has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer