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

download-with-webtorrent-button

v1.0.5

Published

Transform ordinary download links into super-powered WebTorrent ones!

Downloads

6

Readme

download-with-webtorrent-button

Transform ordinary download links into super-powered WebTorrent ones!

Example

Check out the demo page: https://wmhilton.com/download-with-webtorrent-button

screenshot of WebTorrent button

Rationale

Do you have a big, popular file that lots of people download and the Internet would grind to a halt if your website went down? It is EASY to spread the burden of hosting a file among all the people who are downloading it. Bittorrent (despite its association with piracy) is a fabulous network protocol that does exactly that. It use to be that you needed to install separate software to use Bittorrent, but with the advent of WebTorrent it is now possible to use the Bittorrent protocol seamlessly in the browser without visitors ever having to leave your site!

Despite how FREAKING AWESOME WebTorrent is, not enough sites are taking advantage of it. To make taking advantage of WebTorrent as easy and accessible as possible, I decided to make a "Download with WebTorrent" button that turns your ordinary download link into a super-powered WebTorrent download link! All you have to do is paste a small code snippet in your HTML.

Installation using a CDN

Add the following stylesheet to <head>:

<link rel="stylesheet" href="https://unpkg.com/download-with-webtorrent-button/dist/index.css">

And the following scripts to the bottom of <body>:

<script src="https://unpkg.com/webtorrent/webtorrent.min.js"></script>
<script src="https://unpkg.com/download-with-webtorrent-button/dist/index.js"></script>

This adds a single function registerWebtorrentLinks() to the global scope. It automatically initializes a tags. If you add additional a tags after the initial page load (such as in the case of single page apps) you can rerun registerWebtorrentLinks().

If you want to override the CSS styles, take a look at index.css.

Installation using a module bundler?

Somebody should fork this and make it a React component. Pull requests welcome!

Usage

The easiest way

To add a Download with WebTorrent button to your page, use a regular <a> link. The link's href attribute will be provided as a fallback on browsers that can't run WebTorrent, or if an error occurs. Then add a data-webtorrent attribute.

You can use data-webtorrent="auto" and these fabulous free services will auto-generate a WebTorrent-compatible .torrent file for your link.

<a href="file.mp4" data-webtorrent="auto">Link Text</a>

Bring your own torrent

If you already have a magnet URI, you can use that,

<a href="file.mp4" data-webtorrent="magnet:?xt=urn:btih:...">Link Text</a>

or the location of a .torrent file,

<a href="file.mp4" data-webtorrent="https://example.com/path/to/file.torrent">Link Text</a>

but know that WebTorrent is not yet compatible with the DHT and requires ws or http trackers. If your .torrent only includes udp trackers or is tracker-less and relies on the DHT, you are better off using data-webtorrent="auto".

If your torrent is a folder torrent rather than a single file, add a data-file attribute with the name of the individual file you intend the link for.

<a href="https://webtorrent.io/torrents/Sintel/Sintel.mp4" data-webtorrent="magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent" data-file="Sintel.mp4">Sintel</a>

License

Copyright 2017 William Hilton. Licensed under The Unlicense.