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

ejs2

v2.1.0

Published

EJS v2

Downloads

102

Readme

EJS2

EJS2 is a reimplementation of visionmedia's EJS node module. A fair amount of code is copied straight over, but improvements have been made.

It's built to use async functions (as in, readFile with callbacks rather than readFileSync) and to have more maintainable code. It also makes it more extensible as async functions can be added in (which will help with rendering in serenity).

Usage

Pretty much the same as the original, one or two changes.

var EJS = require('ejs2');
var ejs = new EJS({ cache: true }); // cache is enabled by default, equivalent is just `var ejs = new EJS();`

ejs.render('i am an EJS string', {opts: 'go here'}, function(err, html) {
  // you have html!
});

ejs.renderFile('/my/ejs/file.ejs', {opts: 'still go here'}, function(err, html) {
  // you have more html!
});

Benchmarks

For some strange reason, the original EJS is faster with the cache disabled (I assume readFileSync is slightly faster, but of course it's bad practise and blocks the process). EJS2 is slightly faster with the cache enabled. The differences are up to a couple of hundredths of a millisecond. Running the benchmarks on different file types would help, as I believe EJS2 will be quicker when there are includes in the file.

Cache Enabled

EJS2

➜  CACHE=true NUM=100000 node test/bench.js

SYNC
--> 100000 renderfiles in 3.223761557s
--> 0.032237615569999996ms per render
--> 0.01876155699999981s estimated process lock
--> 0.00018761556999999813ms lock per render

PARALLEL
--> 100000 renderfiles in 2.608808327s
--> 0.026088083270000003ms per render
--> 2.608808327s estimated process lock
--> 0.026088083270000003ms lock per render

EJS

➜  CACHE=true NUM=100000 node test/benchOld.js

SYNC
--> 100000 renderfiles in 3.109851967s
--> 0.03109851967ms per render
--> 0.03085196700000006s estimated process lock
--> 0.00030851967000000057ms lock per render

PARALLEL
--> 100000 renderfiles in 2.667056251s
--> 0.02667056251ms per render
--> 2.667056251s estimated process lock
--> 0.02667056251ms lock per render

Cache Disabled

EJS2

➜  NUM=100000 node test/bench.js

SYNC
--> 100000 renderfiles in 18.18666498s
--> 0.1818666498ms per render
--> 0.7826649800000014s estimated process lock
--> 0.007826649800000014ms lock per render

PARALLEL
--> 100000 renderfiles in 13.030406746s
--> 0.13030406746ms per render
--> 13.026406746000001s estimated process lock
--> 0.13026406746ms lock per render

EJS

➜  NUM=100000 node test/benchOld.js

SYNC
--> 100000 renderfiles in 10.333011529s
--> 0.10333011529ms per render
--> 0.3390115289999994s estimated process lock
--> 0.0033901152899999945ms lock per render

PARALLEL
--> 100000 renderfiles in 9.438156485s
--> 0.09438156485ms per render
--> 9.438156485s estimated process lock
--> 0.09438156485ms lock per render