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

laissez-list

v0.0.2

Published

xtal-vlist provides a declarative virtual list web component

Downloads

6

Readme

laissez-list

Actions Status

laissez-list provides a declarative "lazy loading" list web component.

It serves a similar purpose to "virtual list" components, but strictly speaking it isn't a virtual list because of one key difference: It never removes content after it's been created.

Some advantages of a lazy-loaded list vs a virtual list:

  1. If the user starts to edit a part of the list, and then scrolls away, and then comes back again, focus might not be lost. Other changes that might have been incurred by user interaction are also much less likely to be lost with this approach.
  2. As content lazy loads, it permanently becomes searchable via the browser's search tool.
  3. Because it leans more on native browser capabilities, it may work better as far as accessibility.
  4. The complexity and size of the code base is reduced.

Disadvantages:

  1. True "infinite scrolling" would require infinite memory.

To work well with laissez-list, components should use be-oosoom techniques to indicate how to "go to sleep" when scrolling out of view, which simply requires adding a "beOosoom" mapping property to the component. be-repeated is one such component that is be-oosoom friendly.

Another feature that makes laissez-list's performance come close to a virtual list is use of "time-stamping" of items in the list, so that the renderer knows how to rebind items which have changed since the last render. xtal-tree is an example of a time-stamping virtual model, that takes an object structure, and turns it into a flat list, with time-stamping support.

Demo 1 -- Simple

Demo 2 -- Tree View

Note that for Demo 2, if you click expand all, and enable Chrome's Web Vitals dev tool (under rendering tab), there is no Cumulative Layout Shift.

This is done by utilizing the intersectional settings:

<laissez-list ...
  row-intersectional-settings='{
    "rootClosest": ".scroller",
    "options": {
        "rootMargin": "300px",
        "threshold": 0
    }
}'>
 ...
</laissez-list>

API

Example

<laissez-list style="height:600px;width:100%;" id="lzlist"
    row-transform='{
        "span": "."
    }'
>
    <template slot=row>
        <div>
            <span></span>
        </div>
    </template>
</laissez-list>
<script>
    const list = [];
    for (let i = 0; i < 100000; i++) {
        list.push(i);
    }
    lzlist.list = list;
</script>

The row-transform syntax is based on css-like Declarative Trans-Render syntax (DTR).

Installation

  1. npm instal laissez-list
    1. In JS, import 'laissez-list/laissez-list.js';

or

  1. jsDelivr
<script type=module>
    import 'https://esm.run/laissez-list/laissez-list.js';
</script>

Viewing Your Element Locally

$ npm install
$ npm run serve