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 🙏

© 2026 – Pkg Stats / Ryan Hefner

datatable-jh

v1.0.0

Published

datatable-jh is a lightweight JavaScript datatable plugin built on jQuery that helps you create dynamic, searchable, and customizable HTML tables with ease.

Readme

DatatableJh

A lightweight, customizable AJAX-powered datatable built with JavaScript + jQuery, featuring pagination, search, per-page limits, and action dropdowns. Designed to work smoothly with REST APIs (Laravel-friendly).

✨ Features

  • AJAX data loading (GET API)
  • Dynamic columns
  • Server-side pagination
  • Search support
  • Per-page limit selector
  • Action dropdown per row
  • Custom column render support
  • Simple reload method

📦 Installation

npm install datatable-jh

📌 Requirements

  • jQuery >= 3.x
  • Payload must be JSON:
{
  "page": 1,
  "per_page": 5,
  "search": ""
}
  • API must return JSON in the following format:
{
  "currentPage": "1",
  "data": [],
  "totalItems": 0,
  "totalPage": 0
}

🚀 Usage

HTML Structure & ID Conventions

DatatableJh relies on strict ID-based selectors to automatically bind pagination, search, and limit controls to a table instance.

All related elements must share the same base tableId, using the following format:

<tableId>-limit
<tableId>-search
<tableId>-total-items
<tableId>-prev
<tableId>-pagination
<tableId>-next

This convention allows multiple datatables to coexist on the same page without conflicts.

Example (tableId = "users-table")

<select id="users-table-limit"></select>

<input id="users-table-search" type="text" placeholder="Search..." />

<table id="users-table">
  <thead>
    <tr></tr>
  </thead>
  <tbody></tbody>
</table>

<p id="users-table-total-items">Showing 1 to 3 of 3 entries</p>

<button id="users-table-prev">Previous</button>

<ul id="users-table-pagination"></ul>

<button id="users-table-next">Next</button>

JS

import DatatableJh from "datatable-jh";
const userDatatable = new DatatableJh({
  tableId: "users-table",
  apiEndpoint: "/api/users",
  columns: [
    { key: "id", label: "ID" },
    { key: "name", label: "Name" },
    { key: "email", label: "Email" },
    {
      label: "Status",
      key: "status",
      render: (value) => `<span>${value}</span>`,
    },
  ],
  actions: [
    {
      label: "Edit",
      callback: (item) => (window.location.href = `/users/${item.id}/edit`),
    },
  ],
  perPageOptions: [5, 10, 25, 50],
  initPerPage: 10,
});

⚙️ Constructor Options

| Option | Type | Required | Description | | ---------------- | ------ | -------- | ---------------------- | | tableId | string | ✅ | Base ID of the table | | apiUrl | string | ✅ | API endpoint | | columns | array | ✅ | Table columns | | actions | array | ❌ | Row action buttons | | perPageOptions | array | ❌ | Limit dropdown options | | initPerPage | number | ❌ | Default items per page |

🧩 Column Definition

{
  label: "Name",
  key: "name",
  render: (value, row) => {
    return `<strong>${value}</strong>`;
  }
}
  • render is optional
  • Receives (value, fullRow)

🧨 Action Definition

{
  label: "Edit",
  class: "text-blue-500",
  addClass: "extra-class",
  callback: (row) => {}
}

🔄 Reload Data

userDatatable.reload();

📡 API Parameters Sent

GET /api/users?page=1&per_page=10&search=abc

🛠 Laravel Example Response

return response()->json([
    'totalItems' => $users->total(),
    'data' => $users->items(),
]);

💡 Notes

  • Fully framework-agnostic (works with Laravel, Express, etc.)
  • Styling uses utility classes (Tailwind-friendly)
  • No external datatable dependency