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

easy-gist-async

v0.9.2

Published

Simple plugin to load Github Gists in async manner after the document was rendered.

Downloads

4

Readme

easy-gist-async

About Easy-Gist-Async

easy-gist-async is a simple function which loads Github gists in async manner after the document DOM was already rendered/changed.

In case you're using a custom frontend framework to parse content from a Headless CMS, you might want to have some flexibility in rendering your articles. Specifically, if you'd try to import full @html to an existing DOM element, the GitHub Gist embed code won't work. What easy-gist-async does, it searches for markup snippet with gist data in the content and loads gist along with proper css stylesheet afterwords.

This way, you can load your gists in async manner after the page was rendered.

This also means, that you have to take care about using easy-gist-async function in a proper place and time by yourself (i.e. using your framework lifecycle tools or window.onload event. For more details see examples below)

Demo | Blog-post example

Getting started

  1. Install the package from npm

npm i easy-gist-async

  1. Import it into your project
// As an ES6 Module
import gistLoader from 'easy-gist-async';
  1. Use markup snippets for Gists

easy-gist-async expects a div element with gist data in its attributes.

Use the following format to include the full gist using its url.

<div data-gist="https://gist.github.com/someuser/34261e6026oi4c303c40c6ece9961182">

Here: [data-gist] - the url of your Gist *required

If you want to include just one file from the Gist, add optional [data-file] attribute:

<div data-gist="https://gist.github.com/someuser/34261e6026oi4c303c40c6ece9961182" data-file="01_file.js" >

How to load GitHub gists in a Svelte component

<script>
import gistLoader from 'easy-gist-async';
import { beforeUpdate, tick } from 'svelte';

beforeUpdate(async() => {
    await tick();
    gistLoader();
	});

</script>

Changelog