Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detective-html

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detective-html

Find the dependencies of an HTML file.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm cover node size

node-detective-html

Find the dependencies of an HTML file.

npm install detective-html

It's the HTML counterpart to detective, detective-amd, detective-es6, detective-sass.

  • The AST is generated using the parse5 parser.

Usage

const fs = require("fs");
const detective = require("detective-html");

const content = fs.readFileSync("index.html", "utf8");

// list the names of the used files (ex: 'foo.css', 'foo.png', etc)
const dependencies = detective(content);

Non-standard attributes

In many cases, data-src,... are used to lazy load images

This is possible detective outputs such non-standard attribute dependencies by adding a list of html tags and associated specific attributes. The way it is provided is similar to what webpack uses.

const options = {
  sources: {
    list:
      [
        "...",
        { tag: "img", attribute: "data-src", type: "src", },
        { tag: "img", attribute: "data-srcset", type: "srcset", },
        { tag: "source", attribute: "data-src", type: "src", },
        { tag: "source", attribute: "data-srcset", type: "srcset", },
      ]
  }
}
const dependencies = detective(content, options);

License

MIT

Keywords

FAQs

Package last updated on 22 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc