🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

html-inject-script

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-inject-script

Transform stream for injecting script tags into html.

latest
npmnpm
Version
2.0.0
Version published
Weekly downloads
3.8K
-22.34%
Maintainers
1
Weekly downloads
 
Created
Source

html-inject-script

Transform stream for injecting script tags into html.

example:

var injectScripts = require('html-inject-script')

process.stdin
.pipe( injectScripts(['./app.js', './extra.js']) )
.pipe( process.stdout )

input:

<html><head></head><body>hello</body></html>

output:

<html><head><script src="./app.js"></script><script src="./extra.js"></script></head><body>hello</body></html>

api

require('html-inject-script')(scripts[, opts])

Injects an array of scripts. Accepts an object of options:

  • selector (string, default: 'head'): A hyperstream selector into which the tags are injected
  • prepend (boolean, default: true): If true, prepends. If false, appends.

cli

cat index.html | htmlinjectscript "app.js" > output.html
usage: cat index.html | htmlinjectscript "app.js" > output.html

Options:

      --body  -b,  inject into the body element (default: head)

   --selector -s,  override head or body with a specific selector

     --append -a,  append to selector instead (default: prepend)

          --help,  -h  display this message

Gotcha:

requires the tag (head, body, or otherwise) to be present in the src.

FAQs

Package last updated on 21 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts