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 🙏

© 2025 – Pkg Stats / Ryan Hefner

pawajs-dom-rerender

v0.0.15

Published

Pawajs dom diffing for server html with the current dom

Readme

pawajs-dom-reRender

for pawajs dom diffing with server html (pawa-ssr)

import {pawaRender} from 'pawajs-dom-reRender'

try {
    //fetch url
    // Fetches the HTML content from the specified URL.
    const href = await fetch('/the url to fetch')
    href.text().then(res =>{
        //parse html
                // Creates a new DOMParser to parse the fetched HTML string.
                const parser = new DOMParser()
                //fetch html from server
        // Parses the fetched HTML string into a Document object.
        const app = parser.parseFromString(res, 'text/html')
            //fetch mainScript
        // Selects the script element marked with 'page-script' from the fetched HTML.
        const mainScript=app.body.querySelector('[page-script]')
        // Selects the new application root element from the fetched HTML based on the current app's ID.
        const newApp=app.body.querySelector('#'+pageApp.getAttribute('id'))
        // Updates the document title with the title from the fetched HTML.
        document.title=app.title
        // Gets the 'page-url' attribute from the current application's page URL element.
        const pageUrl=pageApp.querySelector('[page-url]').getAttribute('page-url')
        // Gets the 'page-url' attribute from the new application's page URL element.
        const newAppUrl= newApp.querySelector('[page-url]').getAttribute('page-url')
        // Creates a clone of the new application element.
        const clone=newApp.cloneNode(true)
        console.log(pageApp,newApp);
        
            // Checks if the page URL has changed.
            if (pageUrl !== newAppUrl) {
                
                // If a main script is present in the new HTML.
                if (mainScript) {
                    
                    // Selects the current script element marked with 'page-script' in the document body.
                    const currentScript=document.body.querySelector('[page-script]')
                    // Creates a comment node to temporarily replace the script.
                    const comment =document.createComment('script')
                    // Creates a new script element.
                    const newScript=document.createElement('script')
                     newScript.setAttribute('src',mainScript.getAttribute('data-client-src'))
                    
                    // Sets an onload event handler for the new script.
                    newScript.onload = () => {
                        
                      pawaRender(pageApp,newApp)
                     // console.log(appRecorder)
                    };
                    // If a current script exists, replace it with the new script.
                    if (currentScript) {
                         currentScript.replaceWith(comment);
                    comment.parentElement.insertBefore(newScript, comment);
                    comment.remove();
                    }else{
                        pageApp.parentElement.insertBefore(newScript,pageApp)
                    }
                // If no main script is present, just re-render the page.
                } else {
                    pawaRender(pageApp,newApp)
                }
            // If the page URL has not changed, just re-render the page.
            }else{
                pawaRender(pageApp,newApp)
            }
            })
} catch (error) {
    console.log(error);

}

#⚠️ pawajs-dom-reRender is a diff engine and not a v-dom engine

  • more update coming soon....
  • currently pawajs-dom-reRender isn't capable to reArrange the element perfectly now so server loop filtering won't work perfectly but its capable to do it so we currently working on it.

MIT LICENSE