Skip to content

A Transform stream that allows you to inject inline javascript into an html text stream.

Notifications You must be signed in to change notification settings

dlmanning/script-injector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#script-injector

  1. provides a through stream that allows you to inject inline javascript into an html text stream.
  2. Uses trumpet to parse your html.
  3. Should only be used for good, never for evil

Installation

npm install script-injector

How to use

Just pipe a stream of html through script-injector. You can pass in either some stringified code or a function object. What could be easier?

scriptInjector = require('script-injector');

// Then do something like this somewhere else

fs.createReadStream('anHTMLFile')
  .pipe(scriptInjector(aFunction))
  .pipe(someOtherPlace);

script-injector will insert the provided code before your first script tags, or just before </body> if you don't have any other scripts.

About

A Transform stream that allows you to inject inline javascript into an html text stream.

Resources

Stars

Watchers

Forks

Packages

No packages published