npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-feature-detect

v1.0.1

Published

A lightweight library to detect support for specific JavaScript features, CSS properties, and ECMAScript versions in the browser.

Downloads

14

Readme

js-feature-detect

js-feature-detect 是一个用于检测浏览器是否支持特定的 JavaScript 特性、CSS 属性以及 ECMAScript 版本的小型库。它可以帮助开发者确保他们的应用在目标浏览器中能够正确运行,并提供了一种简单的方式来判断当前环境是否满足最低要求。

A lightweight library to detect support for specific JavaScript features, CSS properties, and ECMAScript versions in the browser.

| filename | original | gzip | | ----------------------------- | -------- | ------- | | dist/js-feature-detect.umd.js | 6.30 kB | 1.82 kB | | dist/js-feature-detect.mjs | 6.78 kB | 1.84 kB |

安装

你可以通过 npm 或 yarn 来安装 js-feature-detect

npm install js-feature-detect
# 或者
yarn add js-feature-detect

如果你不想使用包管理器,也可以直接将 UMD 构建版本加入到你的 HTML 文件中:

<script src="https://unpkg.com/js-feature-detect/dist/js-feature-detect.umd.js"></script>

然后可以通过全局变量 JSFeatureDetect 访问 API。

现代与基础浏览器检查

  • isModernBrowser(): 检查浏览器是否支持现代的 JavaScript 运行时和浏览器 API(基于 Vite 的基础浏览器列表)。
  • isBaseSupportBrowser(): 检查浏览器是否支持基本的 JavaScript 运行时和部分关键特性。

使用示例

import { isModernBrowser, isBaseSupportBrowser } from "js-feature-detect";

if (isModernBrowser()) {
  console.log("此浏览器支持现代特性!");
} else if (isBaseSupportBrowser()) {
  console.log("此浏览器支持基础特性,但可能缺少某些现代特性。");
} else {
  console.log("此浏览器不支持所需的特性,请考虑升级您的浏览器。");
}

贡献

我们欢迎任何形式的贡献!无论是报告问题、提出新特性或是提交修复,都是极好的。请先阅读我们的贡献指南。

许可证

Apache-2.0