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

think-ls

v0.0.4

Published

think-ls

Readme

think-ls

基于thinkjs 2.x

方便的使用localstorage存放静态资源,思路点这里:设计localStorage更新

使用

下载安装

npm install think-ls

引用和配置

// middleware.js里注册
import ls from 'think-ls';
think.middleware('think-ls', ls);

// hook.js里配置
view_filter: ['think-ls']

// config/ls.js 配置
{
    // 是否开启
    on: true,

    // css配置
    css: {
        // 以 id:uri路径 的形式, uri以 think.RESOURCE_PATH 为起始路径
        id: '/static/dist/a.css'
    },

    // js配置
    js: {
        id: '/static/dist/a.js',
        global: '/static/dist/b.js'
    },

    // 可选配置
    options: {
        // 开始标签
        open: '{%',

        // 结束标签
        close: '%}'
    }
}

加载静态js

模板调用之前加载static/LS.js到模板中,一般加载在<head>结束前

模板调用

调用css
<%css('id')%>

调用js
<%js('id')%>

主动编译

主动编译一般在资源被修改后触发,这样可以把资源缓存起来,读取页面模板调用时可以快速判断版本并加载文件

// 该代码需要在thinkjs实例化后调用
var ls = require('think-ls');
new ls().build().then(function(a){
    console.log('编译ls结束~');
});

todo

  • 对远程(http)文件的支持,目前只支持在think目录里引用
  • think.cache调用的优化,目前所有的配置都在一个cache里,由于多个css,jssource可能很大,后续考虑以css.key来存放

LICENSE

MIT