npm package: @skriptx2/vanillagrid
Description: Vanilla Grid is a lightweight and minimalist CSS grid system for building responsive, modern layouts with ease. It offers a clean, class-based approach and is ideal for projects that prioritize performance, simplicity, and maintainability.
Author: Alaksandar Jesus Gene AMS
Latest version: 1.1.1

**Vanilla Grid: A Lightweight Alternative to DataTables.net**

In the world of web development, working with tabular data is a common requirement. Popular tools like DataTables.net provide extensive features, but they often come with heavy dependencies, larger file sizes, and performance trade-offs for smaller projects. For developers seeking a lightweight, dependency-free, and efficient grid solution, Vanilla Grid is an excellent alternative. With a file size of only 8KB, Vanilla Grid proves that less is more when it comes to simplicity and speed.

### What is Vanilla Grid?

Vanilla Grid is a minimalist JavaScript library designed for rendering and managing tabular data in web applications. Unlike traditional grid libraries that rely on frameworks like jQuery or large JavaScript ecosystems, Vanilla Grid is completely dependency-free. Its small footprint ensures rapid loading times and makes it particularly suited for projects where performance and simplicity are paramount.

### Key Features of Vanilla Grid

1. **Lightweight and Fast**: At just 7KB, Vanilla Grid and 6KB for Vanilla Server minimizes the impact on your application’s load time.
2. **Dependency-Free**: It doesn’t rely on jQuery, React, or any other libraries, making integration straightforward and conflict-free.
3. **Easy to Use**: With a simple API, Vanilla Grid allows developers to quickly set up and configure tables.
4. **Customizable**: Despite its small size, it offers flexibility in terms of styling and functionality.
5. **Responsive Design**: Vanilla Grid ensures your tables look great on all devices.
6. **Core Functionality**: Provides essential features like sorting, filtering, and pagination without the bloat of unnecessary options.

### Why Choose Vanilla Grid Over DataTables.net?

While DataTables.net is a powerful tool, it may not always be the right fit for every project. Here’s why Vanilla Grid could be a better choice:

- **Smaller Projects**: For simple applications or dashboards, DataTables.net’s extensive feature set can be overkill. Vanilla Grid provides just what you need without the overhead.
- **No Dependencies**: DataTables.net relies on jQuery, which can increase your project’s size and complexity. Vanilla Grid operates independently, simplifying development.
- **Performance**: In scenarios with smaller datasets or limited client-side processing, Vanilla Grid’s lightweight nature ensures snappy performance.
- **Customization**: Vanilla Grid’s straightforward architecture makes it easy to tailor to your project’s specific needs without diving into a complex configuration.

### Getting Started with Vanilla Grid

Here’s a quick guide to setting up and using Vanilla Grid:

1. **Download Vanilla Grid**: Grab the latest version from the official repository or CDN.

```

npm i @skriptx2/vanillagrid


```

2. **Include the Script**: Add the Vanilla Grid JavaScript file to your project:

   ```js
   <script type="module">
        import {VanillaGrid} from './dist/vanillagrid.js';
      window.addEventListener("DOMContentLoaded", function () {
        const table = document.querySelector("table");

        new VanillaGrid(table, {
          itemsPerPage: 5,
          info:'Showing :start to :end of :total entries',
        });
      });
    </script>
   ```

3. **Style Your Table**: Apply custom styles via CSS to match your application’s design.

4. **Refer our demos to pass CSS classes**: We have demos for vanilla css, bootstrap and bulma implementation on vanilla-grid demos repository

**For Bootstrap**

```js
import { VanillaGrid } from "@skriptx2/vanillagrid";

 window.addEventListener("DOMContentLoaded", function () {
   const table1 = document.querySelector("table.table-1");

   new VanillaGrid(table1, {
     itemsPerPage: 10,
     info: "Showing :start to :end of :total entries",
     classNames: {
       wrapper: "d-flex justify-content-between align-items-center",
       ul: "pagination",
       li: "page-item",
       button: "page-link",
       select: "form-select",
     },
   });

```

** For Server Side Rendering **

```js
     const instance = new VanillaServerGrid(wrapper, {
         itemsPerPage: itemsPerPage,
         totalItems: totalItems
         currentPage: page,
         info: "Showing :start to :end of :total entries",
         classNames: {},
       });

       instance.addEventListener("onPageChange", function ({ detail }) {
         drawTable(detail.pageSelected);
       });
```

### Demos

Working Demo: https://vanillagriddemos.web.app

Demo Source: https://github.com/skriptxadmin/vanilla-grid-demos.git

Server Demo: https://vanillagriddemos.web.app/server/index.html

Server Source: https://github.com/skriptxadmin/vanilla-grid-demos/blob/main/src/server/app.js

### When to Use Vanilla Grid

Vanilla Grid is ideal for projects that:

- Prioritize performance and simplicity.
- Avoid adding unnecessary dependencies.
- Handle small to medium-sized datasets.
- Require only core table functionalities like sorting and filtering.

### Limitations to Consider

While Vanilla Grid offers many advantages, it may not be the best choice for every use case. For large-scale enterprise applications requiring advanced features like server-side processing, dynamic column generation, or extensive plugin ecosystems, more robust libraries like DataTables.net may be preferable.

### Conclusion

Vanilla Grid strikes an elegant balance between functionality and minimalism. Its lightweight, dependency-free nature makes it a compelling choice for developers looking for a simple yet effective grid solution. By opting for Vanilla Grid, you can create fast, responsive, and easily customizable tables without the bloat of larger libraries. Whether you’re building a personal project or a professional application, Vanilla Grid is worth considering as a streamlined alternative to traditional grid tools.