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

swaptags

v0.1.1

Published

Util for swapping one set of script <tags> out for another.

Downloads

3

Readme

swaptags

A small script for swapping <script> tags out of an html file and replacing them with the production versions.

To use:

  1. Set up a json file that contains the tags that it should replace as the keys and the values it should replace them with. For example: { "":
    " <script src="underscore-min.js"> <script src="d3.v3.min.js"> <script src="sprigotclient.js"> " } It's OK to have line breaks in the JSON values for now, as it will clean them out before parsing. (In the future, swaptags might use a format that's friendlier to line breaks.) The tag can be any string, but html comments work well in html files.

  2. Use those tags in the source html file to mark off what you want replace. Example:

     <!-- tagsfordev -->
     <script src="lib/underscore.js"></script>
     <script src="lib/d3.v3.js"></script>
     <script src="camera.js"></script>
     <script src="sprig-d3_relations.js"></script>
     <script src="caseData.js"></script>
     <script src="uid.js"></script>
     <script src="network.js"></script>
     <script src="okcanceldialog.js"></script>
     <script src="store.js"></script>
     <script src="treerenderer.js"></script>
     <script src="treenav.js"></script>
     <script src="graph.js"></script>
     <script src="textstuff.js"></script>
     <script src="divider.js"></script>
     <script src="historian.js"></script>
     <script src="sprigot.js"></script>
     <script src="direct.js"></script>
     <!-- tagsfordev -->
  3. Run the script like so:

    node swaptags.js index.html prodreplacements.json dist/index.html

You will end up with an html file that looks like so:

    <html>
    <head>
      <title>Sprigot</title>
      <link rel="stylesheet" type="text/css" href="sprig.css" />
    </head>

    <body>

      <script src="underscore-min.js"></script>      <script src="d3.v3.min.js"></script>      <script src="sprigotclient.js"></script>


    </body>
    </html>

Which, yeah, could look better.

It doesn't handle:

  • Opening and closing tags on the same line.
  • Tags broken across multiple lines.
  • Probably all sorts of other stuff.