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

remove-empty-divs

v1.0.1

Published

A package to remove empty divs from the current HTML page

Downloads

6

Readme

remove-empty-divs

A simple utility function to remove empty div elements from the current HTML page. This package is designed for use in web applications where cleaning up empty div elements is needed.

Installation

You can install the package via npm if it's published:

npm install remove-empty-divs

Or, if you're using it locally for development or testing, you can link it:

  1. Navigate to the package directory and run:

    npm link
  2. In your React application directory, run:

    npm link remove-empty-divs

Usage

In a TypeScript React Project

  1. Import the Function

    Import the removeEmptyDivs function into your React component:

    import removeEmptyDivs from "remove-empty-divs";
  2. Use the Function

    Call the function within a useEffect hook to ensure it runs after the component mounts:

    import React, { useEffect } from "react";
    import removeEmptyDivs from "remove-empty-divs";
    
    const App: React.FC = () => {
      useEffect(() => {
        // Call the function to remove empty divs
        removeEmptyDivs();
      }, []);
    
      return (
        <div className="App">
          <div>
            <p>Non-empty div</p>
          </div>
          <div></div>
          <div>
            <span>Another non-empty div</span>
          </div>
          <div></div>
        </div>
      );
    };
    
    export default App;

In a Plain JavaScript Project

  1. Import the Function

    import removeEmptyDivs from "remove-empty-divs";
  2. Use the Function

    Call the function in your JavaScript code:

    document.addEventListener("DOMContentLoaded", () => {
      removeEmptyDivs();
    });

API

removeEmptyDivs()

This function iterates over all div elements in the current HTML page and removes those that do not contain any child nodes.

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes.
  4. Open a pull request with a description of your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

  • React - For building modern user interfaces.
  • TypeScript - For adding static type checking to JavaScript.

Feel free to modify and extend this README to better fit your project's needs.

Explanation

  • Installation: Instructions for both published and local installations.
  • Usage: How to use the package in a TypeScript React project and a plain JavaScript project.
  • API: Description of the removeEmptyDivs function.
  • Contributing: Guidelines for contributing to the project.
  • License: Licensing information.