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

ssdom

v1.5.1

Published

Server Side DOM

Downloads

4

Readme

ssdom - Server Side DOM

This is a standalone application to create a server side dom. I made it to replace my old server side dom sdom.

ssdom heavily uses jsdom to run the server side dom. If there are any dom features not present I'd recommend forking jsdom and implementing it there.

The goal of ssdom is to be light weight and simple. I plan to improve jsdom instead of ssdom.

How to use ssdom

Single site command line:

ssdom /my-website/main.html --port 80

Mutli site command line:

Use {HOSTNAME} in the path argument to insert the hostname to the html path.

ssdom /sites/{HOSTNAME}/main.html --port 80

Programatically

Provide html path string.

var ssdom = require("ssdom");

var server = ssdom("/my-website/main.html");
server.listen(80);

ssdom will then run on your script tags with the attribute context. Valid values for the context attribute are server or server-only. The attribute is completely optional. However if the context attribute is omitted the script will not run on the server.

...
<body>
  <script context="server">
    // this script will run on both the client and server.
  </script>

  <script context="server-only">
    // this script will only run on the server.
  </script>

  <script>
    // this script will only run on the client.
  </script>
</body>
...

If a server or server-only script affects the document's source in anyway it will show up on the client's browser. For example if a server-only script appends a <div> to the body it will be present on the client's browser.

This allows you to handle sensitive data on the server while using the dom or just remove or add content depending on whos viewing it.

Folder Hierarchy

Currently ssdom uses a fixed folder hierarchy where things can be placed. Eventually these should be customizable in one way or another.

/my-website
  /public
    - Files that get served statically to the client and are sometimes loaded on the server as well.
  /private
    /content
      - HTML files which can be retrieved with loadContent() as element objects.
    /data
      - JSON files which can be retrieved with loadData() as js objects.
    /scripts
      - Scripts with context server or server-only are placed in here.

FAQ

(These aren't actually frequently asked questions. I just made them up.)

Q: Custom attributes are supposed to be prefixed with data-. Using an attribute like context is ilegal! A: Valid context attributes get removed before being sent to clients, so this should be a non-issue.