HTML Injector
Browsersync plugin for injecting HTML changes without reloading the browser. Requires an existing page with a <body>
tag.
Install (Node V4.0.0 & above)
$ npm i browser-sync bs-html-injector
Install (Node V0.10.x 0.12.x)
$ npm i browser-sync bs-html-injector@2
Examples & Recipes including html-injection
Options
files - String|Array File watching patterns that will trigger the injection. NOTE: Ensure you are not also watching the same file through the regular Browsersync config - this will cause a full reload and the inject will not happen
browserSync;
restrictions - Array Limit the comparisons to a certain elements.
browserSync;
excludedTags - Array
When working from scratch within the body
tag, the plugin will work just fine. But when you start
working with nested elements, you might want to add the following configuration to improve the
injecting.
browserSync;
Example
Create a file called bs.js
and enter the following: (update the paths to match yours)
// requires version 2.0 of Browsersync or higher.var browserSync = ;var htmlInjector = ; // register the pluginbrowserSync; // now run Browsersync, watching CSS files as normalbrowserSync;
Gulp example
var gulp = ;var browserSync = ;var htmlInjector = ; /** * Start Browsersync */gulp; /** * Default task */gulp;
Grunt example
// This shows a full config file!module { grunt; // load npm tasks grunt; grunt; grunt; // define default task grunt;};