inline-source

Inline all flagged js & css source files

npm install inline-source
1 downloads in the last day
7 downloads in the last week
75 downloads in the last month

Build Status

inline-source

Inline and compress all <script> or <link> tags that contain the inline attribute.

Usage

<!-- project/src/html/index.html -->
<!DOCTYPE html>
<html>
<head>
  <!-- inline project/src/js/inlineScript.js -->
  <script inline src="../js/inlineScript.js"></script>
  <!-- inline project/scripts/inlineScript.js -->
  <script inline src="/scripts/inlineScript.js"></script>
  <!-- inline project/src/css/inlineStyle.css -->
  <style inline href="../css/inlineStyle.css"></style>
</head>
</html>
var inlineSource = require('inline-source')
  , fs = require('fs')
  , path = require('path')
  , htmlpath = path.resolve('project/src/html/index.html');
  , html = fs.readFileSync(htmlpath, 'utf8');

html = inlineSource(htmlpath, html);
npm loves you