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

code-line

v1.2.0

Published

Let your code have line numbers.

Readme

Code-Line.js

Code-line.js is a lightweight plugin, it finds every <pre><code>... in your page, and append line numbers. Most of the features are dependent on CSS to complete, so very flexible & efficient.

It's mainly use with Highlight.js or Prism, but you can also render your code in any way.

GitHub Pages


Demo

Let's demonstrate a "Hello, World!" to you.

(Highlight code by Highlight.js)

java-hello-world

If you like, keep looking down 😆 or see more Example.


Install

HTML

<script src="https://cdn.jsdelivr.net/npm/code-line"></script>

NPM

npm install code-line

Getting Started

The only thing you need to do is:

<script>CodeLine.initOnPageLoad()</script>

Choose the loading time

If you want to customize the loading time:

// Maybe event-triggered or <script> below the html body
CodeLine.load()

important:

If you use Prism as a syntax-highlighter, CodeLine needs to be load() after it. Ex: Prism.hooks.add('complete', CodeLine.load)

Nohighlight

Same as the Highlight.js, to disable code-line altogether use the nohighlight class:

<pre><code class="nohighlight">...</code></pre>

Absolute Position

We usually have to trace codes with mobile devices.

Line-numbers.js use position: absolute default. As a result, you can slide your screen without losing direction and number.

If you don't like it, just append your CSS rules, like:

pre.cljs code {
  position: relative;
}

Soft Wrap

Hard Wrap is the default setting of Code-line. If you want to use Soft Wrap, append soft-wrap class to your <code>:

<pre><code class="soft-wrap">...</code></pre>

Widget

Currently, CodeLine supports two widgets -- CopyButton & LineNumbersToggle.

It may be useful or annoying, you can enable/disable it whatever you love.


Options

| Name | Type | Default | Description | |------------------|-----------|-----------------------------------------------------------------------------------|---------------------------------------------------------------| | minLine | {Number} | 3 | Code below minLine will not be applied | | show | {Boolean} | true | Enable/Disable Line Numbers | | showOnMobile | {Boolean} | false | Enable/Disable Line Numbers on mobile | | softWrap | {Boolean} | false | Enable/Disable softwrap | | maxMobileWidth | {Number} | 420 | Width below the maxMobileWidth will be considered as mobile | | copyBtn | {Object} | {show: true, position: 'bottom', showOnMobile: false, positionOnMobile: 'bottom'} | The setting of the Copy Button | | toggleBtn | {Object} | {show: true, position: 'top', showOnMobile: true, positionOnMobile: 'top'} | The setting of the Line Numbers Toggle Button |

Example:

<script>
  CodeLine.initOnPageLoad({
    showOnMobile: true,
    toggleBtn: {show: true, showOnMobile: false, position: 'bottom'}
  })
</script>