Critical Injector
Injects CSS or JS files contents into HTML file in marked places. Actual detection of critical path CSS should be done by other means. On small pages it can me done manually.
You can keep Your code in separate files, process them by other packages (compile, minify) and finally inject their source.
Install
Install with npm
npm install --save critical-injector
Usage
const criticalInjector = ; var newContent = ;
An example of this in completed form can be seen below:
<!-- injector:css foo bar="baz" --> <!-- endinjector --> <!-- injector:js defer --> <!-- endinjector -->
The resulting HTML would be:
API
criticalInjector(src, options)
src
Type: String
Default: none
File pathname or HTML content.
Options
options.basePath
Type: String
Default: none
Extracted pathnames from [src] or [href] attributes will be appended to basePath.
options.isPath
Type: Boolean
Default: true
Specify if first argument is a pathname or HTML content.