Skip to content

Seven-Y-Q-Guo/oust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oust

[build-your-own] oust

Inspired from https://github.com/addyosmani/oust

API

Options

Attribute Required Description
htmlString True a valid HTML string to parse for references
type True one of stylesheets, scripts, styles, links, images
cb False Filter via callback

Usage

First include:

const oust = require('oust');

Extract stylesheets references <link rel="stylesheet">

console.log(oust('<link rel="stylesheet" href="styles/main.css">', 'stylesheets')); // output: ["styles/main.css"]

Extract stylesheets references with media print <link rel="stylesheet" media="print">

console.log(oust('<link rel="import" href="../polymer/polymer.html">', 'stylesheets', ($el, i) => {
  return $el.attr('media') === 'print';
})); // output: ["../polymer/polymer.html"]

Extract script references <script src>

console.log(oust('<script src="scripts/main.js"></script>', 'scripts')); // output: ["scripts/main.js"]

Extract inline styles <style>...</style>

console.log(oust('<style>body {padding:0}</style><style>h1 {font-size: 5rem}</style>', 'styles')); // output: ["body {padding:0}", "h1 {font-size: 5rem}"]

Extract URL references <a href>

console.log(oust('<a href="contact.html">Contact</a>', 'links')); // output: ["contact.html"]

Extract image source references <img src>

console.log(oust('<img src="http://placekitten.com/200/300">', 'images')); // output: ["http://placekitten.com/200/300"]

About

[build-your-own] oust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published