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 🙏

© 2026 – Pkg Stats / Ryan Hefner

joicomponents

v1.3.6

Published

Design patterns to build native web components

Readme

Web component design patterns

The native web components cookbook

"Web component design patterns" are recipes for simple and reusable web components. All patterns run natively in any browser that supports web components and vanilla es6.

If you have your own use cases, problems, patterns and/or solutions, please let us know!

Chapter 1: How to make a web component?

  1. Intro: Web components
  2. HowTo: CreateElement
  3. HowTo: CreateShadowDom
  4. HowTo: CloseShadowDOM
  5. WhatIs: Upgrade
  6. Pattern: TemplateSwitcheroo
  7. HowTo: attributeChangedCallback
  8. Pattern: TheEnd
  9. Anti-pattern: TwoConstructors
  10. RulesOfThumb for web components

Chapter 2: ShadowDOM

  1. What is: shadowDOM
  2. HowTo: <slot>
  3. HowTo: name <slot>
  4. HowTo: <slot> fallback nodes
  5. HowTo: .assignedNodes()
  6. Pattern: style <slot>
  7. Pattern: ::slotted(*)

Chapter 3: SlotMatroska

  1. HowTo: chain slots
  2. Problem: SlotMatroska
  3. Problem: SlotStyleCreep
  4. Problem: FallbackNodesFallout
  5. Problem: FlattenTrueIsFalse
  6. Problem: NoFallbackSlotchange
  7. Problem: SlotchangeSurprise
  8. Theory: DomNodesAndBranch
  9. Problem: PrematureSlotchange
  10. Problem: SlotchangeNipSlip
  11. Theory: VariableExpectations

Chapter 4: slotCallback(..)

  1. Pattern: NaiveSlotCallback
  2. Pattern: MySlotCallback
  3. Pattern: SlotCallbackAfterDCL
  4. Pattern: PostSlotchangeCallback
  5. Pattern: SlotchangeCallback
  6. Pattern: SlotChildCallback
  7. Pattern: SlottablesEvent
  8. Pattern: SlottablesCallback
  1. Pattern: FalloutFix

Chapter 5: Style

  1. Intro: Style_in_web_comps
  2. HowTo: shadowStyle
  3. Problem: ThisStyleIsNotMyStyle
  4. HowTo: HostWithStyle
  5. HowTo: CssVariables
  6. Pattern: CssCoordinatorClass
  7. Pattern: CssCoordinatorAttribute
  8. Pattern: StyleCoordinatorAttribute
  9. Pattern: NaiveStyleCallback
  10. Mixin: NaiveStyleCallback
  11. HowTo: TraverseTheCssom
  12. Pattern: TreeOrderedCssomTraversal
  13. Mixin: StyleCallback
  14. Test: StyleCallback

Chapter 6: Layout

  1. HowTo: ReactToLayout
  2. Pattern: MediaQueryAttribute
  3. Pattern: ResizeAttribute
  4. Pattern: ResponsiveElement
  5. Problem: DOM_folding
  6. Pattern: NaiveLayoutAttributes
  7. Pattern: LayoutAttributes

Chapter 7: HTML Composition

  1. Pattern: JsonAttributes
  2. Pattern: StubbornAttribute
  3. Introduction: HTML is list
  4. FosterParentChild (<ul-li>)
  5. HelicopterParentChild (<ol>+<li>)
  6. CulDeSacElements (<img>)
  7. MiniMeDOM (make the index in <the-book>+<a-chapter>)
  8. Pattern: JSONAttributes
  9. Discussion: HTML composition

Chapter 8: Mixins

  1. Reactive method
  2. Isolated functional mixin
  3. StaticSetting
  4. EventRecording
  5. DebounceCallbacks
  6. OptionalCallbacksEvents
  7. PrivateSymobl
  8. MixinSingletons
  9. Discussion: isolate FunctionalMixins

Chapter 9: Polyfill web components

  1. Introduction: What's a polyfill?
  2. FeatureDetection
  3. Dynamically loading scripts
  4. FeatureDetectAndPolyfill
  5. Batch calls to customElements polyfill
  6. QueAndRecallFunctions
  7. SuperFun
  8. Polyfill loader
  9. Polyfill loader generator
  10. Sync vs async polyfills
  11. Webcomponentsjs