Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@builder.io/partytown
Advanced tools
Relocate resource intensive third-party scripts off of the main thread and into a web worker.
@builder.io/partytown is a JavaScript library that helps move resource-intensive operations from the main thread to web workers. This can significantly improve the performance of web applications by offloading tasks such as third-party scripts, analytics, and other heavy computations to a background thread.
Offloading Third-Party Scripts
This feature allows you to offload third-party scripts to web workers, reducing the load on the main thread and improving page performance. The code sample initializes Partytown and forwards specific functions to the web worker.
import { init } from '@builder.io/partytown';
init({
forward: ['dataLayer.push'],
});
Web Worker Communication
Partytown enables seamless communication between the main thread and web workers. The code sample demonstrates how to forward a custom function to be executed in a web worker.
import { init } from '@builder.io/partytown';
init({
forward: ['myCustomFunction'],
});
function myCustomFunction() {
console.log('This runs in a web worker');
}
Improving Performance
By offloading resource-intensive tasks to web workers, Partytown helps improve the overall performance of your web application. The code sample shows how to forward a heavy computation function to a web worker.
import { init } from '@builder.io/partytown';
init({
forward: ['heavyComputation'],
});
function heavyComputation() {
// Some resource-intensive task
}
Comlink is a library that simplifies the use of WebWorkers by providing a proxy-based interface for communication. Unlike Partytown, which focuses on offloading third-party scripts, Comlink is more general-purpose and can be used for any kind of task that you want to run in a web worker.
Workerize is a library that automatically moves a module into a WebWorker and returns a proxy to interact with it. It is similar to Partytown in that it helps offload tasks to web workers, but it does not specifically target third-party scripts.
Greenlet is a library that allows you to run a function in a WebWorker and return a promise for its result. It is lightweight and easy to use, but it does not offer the same level of integration for third-party scripts as Partytown.
A fun location for your third-party scripts to hang out
Partytown is a lazy-loaded library to help relocate resource intensive scripts into a web worker, and off of the main thread. Its goal is to help speed up sites by dedicating the main thread to your code, and offloading third-party scripts to a web worker.
Note: Partytown is still in beta and not guaranteed to work in every scenario. Please see our FAQ and Trade-Off sections for more info.
The philosophy is that the main thread should be dedicated to your code, and any scripts that are not required to be in the critical path should be moved to a web worker. Main thread performance is, without question, more important than web worker thread performance.
FAQs
Relocate resource intensive third-party scripts off of the main thread and into a web worker.
The npm package @builder.io/partytown receives a total of 211,108 weekly downloads. As such, @builder.io/partytown popularity was classified as popular.
We found that @builder.io/partytown demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 18 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.