Dependency tracing for HTML, CSS, and JS


stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
Minified + gzip package size for @commonshost/sherlock in KB


@commonshost/sherlock 🕵

Dependency tracing tool for HTML, CSS, and JS files. This can be used with HTTP/2 Server Push to serve websites faster.


Provide a directory path to the folder that includes HTML, CSS, and JS files.

Sherlock returns a Promise which resolves with an array of errors and dependency objects.

Each dependency object has the properties type, parent, and path.

Image dependencies may include the loading property, if set in the HTML source.

Each error object has the properties error and parent.

const sherlock = require('@commonshost/sherlock')

const dependencies = await sherlock(dir)
// [
//   {
//     type: 'application/javascript',
//     parent: '/public/app.js',
//     path:'/public/src/lib.js'
//   },
//   ...
// ]


An Error instance containing some information about the problem.


SyntaxError from Acorn with pos and loc properties and a meaningful message string.


A string containing the MIME type of the dependency. Can be a specific MIME type of a wildcard.


  • application/javascript
  • image/png
  • image/*
  • font/*
  • text/css


A string containing the absolute path to the file referencing the dependency.


  • /some/where/index.html
  • /some/where/app.js
  • /some/where/styles.css


A string containing the absolute path to the referenced file, or external URL. Includes any query string (i.e. ?query) or hash fragment (i.e. #hash).


  • /some/where/images/photo.jpeg
  • /some/where/assets/typeface.woff2
  • /some/where/assets/typeface.woff2?query-string
  • /some/where/assets/typeface.woff2#hash-fragment
  • https://example.net/external-resource


A string containing the value of the loading HTML attribute. Should be either lazy or eager, but the actual HTML value is provided even if it differs so the robustness principle applies.

See Also


Made with ❤️ by Sophie Yang and Sebastiaan Deckers for the 🐑 Commons Host project.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.