Gathering detailed insights and metrics for @purge-icons/core
Gathering detailed insights and metrics for @purge-icons/core
Gathering detailed insights and metrics for @purge-icons/core
Gathering detailed insights and metrics for @purge-icons/core
npm install @purge-icons/core
Typescript
Module System
Node Version
NPM Version
55.3
Supply Chain
98
Quality
74.9
Maintenance
50
Vulnerability
98.9
License
TypeScript (93.08%)
JavaScript (4.64%)
HTML (2.28%)
Total Downloads
1,766,409
Last Day
1,680
Last Week
10,747
Last Month
45,234
Last Year
577,345
228 Stars
94 Commits
18 Forks
6 Watching
1 Branches
10 Contributors
Latest Version
0.10.0
Package Id
@purge-icons/core@0.10.0
Unpacked Size
37.30 kB
Size
9.98 kB
File Count
7
NPM Version
lerna/3.22.1/node@v20.4.0+arm64 (darwin)
Node Version
20.4.0
Publised On
18 Nov 2023
Cumulative downloads
Total Downloads
Last day
-12.7%
1,680
Compared to previous day
Last week
6.5%
10,747
Compared to previous week
Last month
3.8%
45,234
Compared to previous month
Last year
2.7%
577,345
Compared to previous year
It's now recommended to use UnoCSS Icons, unplugin-icons or Iconify Icon Components instead of this approach.
Bundles only the icons you use
Think about TailwindCSS + PurgeCSS, but for Icons.
PurgeIcons is heavily inspired from PurgeCSS. It analyzes your source code or dist files, extracting the icon names you used, and then bundle the icons' data (SVGs) into your code.
You will only get icons you need. No extra bandwidth, no unused icons, no compromise.
Underneath, it's powered by Iconify, which you get access to 80+ popular open source iconsets with over 5,000 icons to choice, including Material Design Icons, Font Awesome, Octicon and even Emojis!
Browser the icon sets in Icônes or Iconify.
Just like what you used to do for Iconify.
1<span class="iconify" data-icon="fa:home"></span>
Or even dynamic
1const span = createElement('span') 2span.class = 'iconify' 3span.data.icon = isDark ? 'carbon:moon' : 'carbon:sun' 4 5// DON'T, PurgeIcons won't extract them correct. 6// add them to `included` to be always bundled if you really want this 7span.data.icon = `carbon:${isDark ? 'moon' : 'sun'}`
PurgeIcons is designed to be framework independent, but using framework plugins is the most recommended way to get started. Check out the supported frameworks in the following list. We are trying to make more frameworks able to use PurgeIcons out-of-box. Pull requests are great welcome!
Plugin | Example | Template | |
---|---|---|---|
Vite | vite-plugin-purge-icons | Example | Vitesse |
Nuxt | nuxt-plugin-purge-module | Example | |
Vue CLI | Coming... | ||
Gridsome | Coming... | ||
Parcel | Coming... | ||
Webpack | purge-icons-webpack-plugin | ||
Rollup | rollup-plugin-purge-icons |
The CLI is still working in progress and the design is not yet finalized.
You can either install PurgeIcons as a dev dependency and use the CLI with npx or you can also install PurgeIcons globally:
1npm i -g purge-icons 2
Scan the all the html file and geneted a mjs
bundle
1purge-icons --content 'src/*.html' --format mjs --output output.js
From multiple sources and use args shorthands, format
can be auto inferred from the output
option
1purge-icons -c 'index.html,src/**/*.vue' -o output.ts
Or export plain json file for other tools to process
1purge-icons -c index.html -o output.json
See more options by
1purge-icons --help
Programmatic API is still working in progress as well.
For programmatic use only, you can use @purge-icons/core
1npm i -D @purge-icons/core
1import { PurgeIconsOptions, PurgeIcons } from '@purge-icons/core'
2
3const code = await PurgeIcons({
4 // globs for searching source file to analyze
5 content: [
6 '**/*.html',
7 '**/*.js',
8 '**/*.vue', // scan for .vue file as well
9 ],
10 // whitelist for icons that might be used dynamically
11 included: [
12 'mdi:account-circle-outline', // from Material Design Icons
13 'fa:camera', // from Font Awesome 4
14 ],
15 format: 'mjs'
16})
17
18// code is generated with inlined icons's data, bundle the file and it's done.
19fs.promises.writeFiles('./icons.mjs', code, 'utf-8')
1export interface PurgeIconsOptions { 2 content?: (string | RawContent)[] 3 included?: string[] 4 extractors?: Extractor[] 5 iconSource?: IconSource // default to 'auto' 6}
Iconify is an icon framework that provide an unified syntax to use icons from its huge collections on-demanded. Each icon set has a id as the prefix of for its icons. For example:
1<span class="iconify" data-icon="fa:home"></span> <!-- Font Awesome --> 2<span class="iconify" data-icon="noto:bird"></span> <!-- Note Icons --> 3<span class="iconify" data-icon="mdi:alert"></span> <!-- Material Design Icons -->
Iconify achieve that by building up a API service that only send the icons you need. It provides a great flexibility that you can try with different design style and without to worry about including a large amount of unused icons that eat up your bandwidth and slow down your page load.
However, the downside of API querying is that the icons won't be available on the first meaningful paint and your app will be heavy relied on the API servers' status and so its accessability for your users. Iconify also provides the offline solution by implementing frameworks components. In that way, you would need to manually import every icon you use.
Thus, PurgeIcons was born. By scanning your code, it generates bundles for Iconify and load them synchronously. You can use icons in the exact same way as you would with the API based solution.
MIT License © 2020 Anthony Fu
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 9/30 approved changesets -- score normalized to 3
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
67 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More