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

vue-devtools-plugin-element-counter

v1.0.0

Published

A Vue Devtools plugin to count the number of elements in Vue Components

Downloads

6

Readme

A Vue Devtools plugin that counts and displays how many element nodes are rendered in a Vue component, helping you discover unnecessary element rendering or excessive element rendering that leads to performance issues.

demo

How to Use

Only support in Vue Devtools 6+, and used vue-demi to support Vue2 and Vue3.

Install dependencies:

npm install vue-devtools-plugin-element-counter

To use in Vite/Webpack projects, it takes effect by default only in the development environment. If you need to enable it in the production environment, refer to:https://vuejs.org/api/compile-time-flags.html#configuration-guides, and set__VUE_PROD_DEVTOOLS__: 'true'

To use in Vue3:

import { createApp } from 'vue'
import type { ObjectPlugin } from 'vue'
import ElementCounterVue3 from 'vue-devtools-plugin-element-counter'
import './style.css'
import App from './App.vue'

const app = createApp(App)
app.use(ElementCounterVue3 as ObjectPlugin)
app.mount('#app')

To use in Vue2:

import Vue from 'vue'
import type { PluginObject } from 'vue'
import App from './App.vue'
import ElementCounterVue2 from 'vue-devtools-plugin-element-counter'

Vue.use(ElementCounterVue2 as PluginObject<never>)
new Vue({
  render: h => h(App),
}).$mount('#app')

The label in the Component Tree does not update in real-time. When your component changes, you can click force refresh in the devtools to refresh the entire Component Tree, or click the corresponding component in the Components Tree and check the current accurate element count in the state panel on the right.

Settings

settings

When the set limit is reached, the label will be highlighted.

Performance

Tested under scenarios with 100 component nesting depths and 10,000+ element nodes rendered simultaneously, the additional performance overhead brought by the plugin in Devtools is negligible.

For more details about the performance

After comparing various methods for counting elements, we found that getElementsByTagName has the best performance. Therefore, except for necessary traversals, all calculations use getElementsByTagName.

  • getElementsByTagName returns a live HTMLCollection, which involves less computation at creation and has a caching mechanism, demonstrating excellent performance in our scenario.
  • querySelectorAll returns a static NodeList, which involves more computation at creation.
  • The efficiency of native browser APIs is always higher than custom-implemented calculation logic.

alt text

  • 19,298,556 indicates that approximately 19,298,556 operations can be completed per second on average during the test
  • ±0.99% indicates the fluctuation range of the performance

You can also find the relevant code in example/performance.html.

Development

Runpnpm install && pnpm dev, and open http://localhost:3000/

Testing

On the basis of the development steps:

  • Install chromium: npx playwright install chromium
  • Run tests: npm test:3 or debug tests: npm test-debug:3