npm.io
1.0.5 • Published 11 years ago

css-claw

Licence
ISC
Version
1.0.5
Deps
0
Vulns
0
Weekly
0

css-claw

A tool to get all CSS and JavaScript file's url on the html page.

Installation

$ npm install css-claw

Usage

var cssClaw = require('css-claw');

cssClaw.getPaths('./index.html', {ecoding: 'utf8'}, function(data){
  console.log(data);
});

API

cssClaw.getPaths(htmlPath, [options], callback)

htmlPath String

options Object

  • cssReg Object regular expression to match all relative url of CSS in the html
  • jsReg Object regular expression to match all relative url of JavaScript in the html
  • encoding String default = 'utf8'

callback: Function

var options = {
  cssReg: /<link[^>]*href=["'](.*\.css)["'][^>]*>/g,
  jsReg: /<script[^>]*src=["'](.*\.js)["'][^>]*>/g,
  encoding: 'utf8'
};

var callback = function(data){
  console.log(data);
  // do something ...
};

cssClaw.getPaths('./index.html', options, callback);

Keywords