find-html-dependencies

Finds all dependencies within an HTML string or codesen parser AST

Usage no npm install needed!

<script type="module">
  import findHtmlDependencies from 'https://cdn.skypack.dev/find-html-dependencies';
</script>

README

find-html-dependencies

Finds all dependencies within an HTML string or codsen-parser AST. A dependency in this case is a resource referenced from the HTML including images, CSS files, and JavaScript files.

Install

$ npm install find-html-dependencies

Usage

const findHTMLDependencies = require("find-html-dependencies");

const dependencies = findHTMLDependencies(`
  <img src="my-image.png" />
`);
// => [ { path: 'my-image.png', range: [ 13, 25 ] } ]

API

findHTMLDependencies(html)

Accepts a string or AST generated by codsen-parser.

Returns an array of objects for each dependency found found.