@finsweet/attributes

中文文档
2.7.1发布于 2026/05/25Apache-2.0ES Module构建来源已验证近 30 天下载 2295

Finsweet Attributes V2

原始使用文档
文档目录6 节
  1. What is Attributes?
  2. Getting Started
  3. API Reference
  4. The FinsweetAttributes object
  5. The FinsweetAttributeControls object
  6. The FinsweetAttributes.utils object
Attributes by Finsweet - Free powerful features for your site, no confusing code

npm Hits License

What is Attributes?

Attributes is an open source JavaScript library of solutions for adding filters, sort, load & search options, CMS tabs & sliders —and more— to Webflow using simple HTML attributes.

Getting Started

Please follow the documentation at finsweet.com/attributes to learn how to use Attributes in your Webflow projects.

API Reference

Attributes will inject a global window.FinsweetAttributes object into your project that contains some methods to interact with the library.

To ensure that the library is loaded before you try to access the window.FinsweetAttributes object, you can use the following instantiation code:

window.FinsweetAttributes ||= [];
window.FinsweetAttributes.push([
  'ATTRIBUTE_KEY', // 'list', 'copyclip', 'modal', etc.
  (result) => {
    // Your code goes here.
  },
]);

The result object will contain the API of the loaded attribute solution. Check the README.md file of each attribute solution for more information on the API.

The FinsweetAttributes object

Properties

PropertyTypeDescription
processSetContains the currently active Attribute solutions.
modulesObjectA key-value object that contains the controls for each active Attribute solution. Each key is the corresponding Attribute's key and each value is a FinsweetAttributeControls object.
utilsObjectContains utility functions for working with Attributes.

Methods

MethodDescriptionArguments
push([key, callback])Run a callback after an Attribute has loaded.key (string): The Attribute key.
callback (function): The callback function.
load(key)Dynamically load an Attribute solution.key (string): The Attribute key.
destroy()Destroys the instance and all Attribute solutions.

The FinsweetAttributeControls object

Properties

PropertyTypeDescription
versionstringThe version of the Attribute.
loadingPromiseA promise that resolves once the Attribute has loaded and returns its API.

Methods

MethodDescriptionArguments
restart()Restarts the Attribute. In practice, this means that the Attribute will be destroyed and loaded again.
destroy()Destroys the Attribute.

The FinsweetAttributes.utils object

type FinsweetAttributesUtils = {
  /**
   * Fetches and parses an external page.
   * Stores the page response in an IndexedDB if the page belongs to the same site.
   *
   * @param source The URL of the page to fetch
   * @param options Optional configuration object
   * @returns Promise that resolves to the page's Document if successful, null otherwise
   */
  fetchPage: (
    source: string | URL,
    options?: {
      cache?: boolean; // Whether to cache fetched documents. Defaults to `true`
      cacheExternal?: boolean; // Whether to cache external documents using a stale-while-revalidate strategy
      cacheKey?: string; // Manual database name for the IndexedDB instance
      cacheVersion?: number; // Manual version for the IndexedDB instance
    }
  ) => Promise<Document | null> | null;

  /**
   * Attaches external stylesheets from a fetched page to the current document head.
   * Only attaches stylesheets hosted on the Webflow Assets CDN that aren't already present.
   *
   * @param page The Document object from which to extract stylesheets
   * @returns Promise that resolves when all stylesheets have been attached
   */
  attachExternalStylesheets: (page: Document) => Promise<void>;
};

版本与发布记录

@finsweet/attributes 共发布 87 个版本,首次发布于 2024/03/22;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.7.1latest2026/05/255 个月前
2.7.02026/05/255 个月前
2.6.332026/04/166 个月前
2.6.322026/04/166 个月前
2.6.312026/03/247 个月前
2.6.302026/03/177 个月前

关于 @finsweet/attributes 的常见问题

@finsweet/attributes 是什么?

Finsweet Attributes V2

如何安装 @finsweet/attributes?

在项目目录运行 npm install @finsweet/attributes,或使用 pnpm add / yarn add / bun add。

@finsweet/attributes 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/finsweet__attributes 是否存在。

@finsweet/attributes 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@finsweet/attributes 可以商用吗?

@finsweet/attributes 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@finsweet/attributes 的下载量有多少?

根据 npm 官方下载统计,@finsweet/attributes 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,295 次,日均约 77 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@finsweet/attributes 还在维护吗?

最新版本 2.7.1 发布于 2026/05/25(5 个月前);至今共发布 87 个版本,其中过去 12 个月发布了 16 个;首次发布于 2024/03/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。