🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

parallel-dom

Package Overview
Dependencies
Maintainers
0
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parallel-dom

pdom

npmnpm
Version
0.7.0
Version published
Weekly downloads
1K
-13.55%
Maintainers
0
Weekly downloads
 
Created
Source


Parallel DOM npm version

Make your apps faster, parallelize away heavy DOM operations.


Usage

Javascript

Example | Demo

import PDom from 'parallel-dom';

const pdom = new PDom(
    // The root, the subtree will be 
    // made parallel.
    '#root', 

    // Javascript entry point of the script 
    // to run parallely inside the parallel subtree.
    () => import('path/to/script/which/runs/in/parallel') 
);
pdom.render();

React

Example | Demo

// parallel-component.tsx
const ParallelComponent = ({ prop1, onCallback }) => {
    // heavy operations.
    // ...
    return <button onClick={onCallback}>{prop1}</button>
}
import PDom from 'parallel-dom/react';

const ParallelComponent = PDom(() => import('./parallel-component'));

export const App = () => {
    const [p1, setP1] = useState('');
    return <>
        ...
        <ParallelComponent prop1={p1} onCallback={cb} />
    </>
}

React limitations

  • Not supported: unserializable props (JSX in props etc.)
  • Callbacks in Props are supported, but they are all async.

Under the hood

  • Creates an iframe on a https://<hash>.pdom.dev domain.
  • Passes the scriptUrl and creates a clone of the passed DOM element to the above frame.
  • The iframe loads and runs the script.
  • Since, iframe is cross origin, the browser creates a dedicated process for it.
  • We use origin-agent-cluster header to enable multiple PDom to have their own dedicated subframe process.

For more details:

FAQs

Package last updated on 02 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts