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

jadum

v1.4.2

Published

A lean Jade compiler that understands Browserify and reuses partials

Downloads

20

Readme

jadum

A lean Jade compiler that understands Browserify and reuses partials

Works just like jade, except that the CLI compiles views producing a syntax like below.

module.exports = function (model) {
  // view rendering...
}

The other difference is that the traditional Jade compiler inlines partials when it finds include statements, whereas jadum uses require statements to reuse partials, saving precious bytes in client-side code.

Install

npm install -S jadum

CLI

The CLI works the same way as the one in jade, but it always compiles views for the client-side, as Common.JS modules.

jadum views/**/* -o .bin

API

The API is the same as the API in Jade, but it produces require statements instead of inlining include statements.

Comparison

Take as input these two files: listing.jade and item.jade.

h1 This is some awesome listing!
ul
  each item in ['a', 'b', 'c']
    include item
li
  span Here comes item:
  span Note that this is quite a big template file
  span But it's included everywhere, because Jade!
  span So that's awesome... but compiling becomes an issue...
  span=item

As the item.jade template grows, every template that depends on it will grow twice as much, as the included template (item.jade) is inlined twice in its parent (listing.jade) template! Here is the output of jade.

function template(locals) {
var buf = [];
var jade_mixins = {};
var jade_interp;

buf.push("<h1>This is some awesome listing!</h1><ul>");
// iterate ['a', 'b', 'c']
;(function(){
  var $$obj = ['a', 'b', 'c'];
  if ('number' == typeof $$obj.length) {

    for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
      var item = $$obj[$index];

buf.push("<li><span>Here comes item:</span><span>Note that this is quite a big template file</span><span>But it's included everywhere, because Jade!</span><span>So that's awesome... but compiling becomes an issue...</span><span>" + (jade.escape(null == (jade_interp = item) ? "" : jade_interp)) + "</span></li>");
    }

  } else {
    var $$l = 0;
    for (var $index in $$obj) {
      $$l++;      var item = $$obj[$index];

buf.push("<li><span>Here comes item:</span><span>Note that this is quite a big template file</span><span>But it's included everywhere, because Jade!</span><span>So that's awesome... but compiling becomes an issue...</span><span>" + (jade.escape(null == (jade_interp = item) ? "" : jade_interp)) + "</span></li>");
    }

  }
}).call(this);

buf.push("</ul>");;return buf.join("");
}

If we use jadum, however, we don't have these issues. We'll always have a fixed size determined by the length of the path passed to require statements. Pretty neat! Since jadum understands Browserify it won't hope for the best, in terms of expecting the Jade runtime to be globally included in your code. That's why there's the extra require at the top for the runtime. Browserify will take over when compiling the template, making sure it's only included once. Furthermore, if you use thee template in various places, then it will only be included once. That's where you save the vast majority of bytes.

var jade = require("jadum/runtime");
module.exports = function listing(locals) {
var buf = [];
var jade_mixins = {};
var jade_interp;
;var locals_for_with = (locals || {});(function (require) {
buf.push("<h1>This is some awesome listing!</h1><ul>");
// iterate ['a', 'b', 'c']
;(function(){
  var $$local = locals["item"];
  var $$obj = ['a', 'b', 'c'];
  if ('number' == typeof $$obj.length) {

    for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
      var item = locals["item"] = $$obj[$index];

buf.push(require("./item").call(this, locals));
    }

  } else {
    var $$l = 0;
    for (var $index in $$obj) {
      $$l++;      var item = locals["item"] = $$obj[$index];

buf.push(require("./item").call(this, locals));
    }

  locals["item"] = $$local;
  }
}).call(this);

buf.push("</ul>");}.call(this,"require" in locals_for_with?locals_for_with.require:typeof require!=="undefined"?require:undefined));;return buf.join("");
}

License

MIT