![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
command-queue-module
Advanced tools
Create simple command queue proxies for modules.
You can boost the initial load performance of a page by requesting some non-crucial scripts asynchronously, but at the same time you might need to queue some calls to these libraries early on.
A common example is event / error tracking - it's not necessary to start sending events right after load, but it's beneficial to start collecting them as early as possible.
This project enables you to create proxy module for any library with the exact same API as the original, but the method calls are stored as commands and invoked only after the actual implementation is loaded.
createCommandQueueModule(methodNames, loadCallback)
methodNames
Type: Array<string>
Array of method names that will be proxied by the command queue. Other methods will not be available neither before or after load.
loadCallback
Type: (onLoad: (actualModule) => void) => void
Callback called right after calling createCommandQueueModule
. It should accept onLoad
function as it's only argument.
onLoad
should be called with the actual module object when it's available.
import()
const createCommandQueueModule = require('command-queue-module');
const myTrackingLibrary = createCommandQueueModule(['trackEvent'], (onLoad) => {
import('my-tracking-library').then(onLoad);
}));
// Works no matter if library is already loaded or not
myTrackingLibrary.trackEvent('Hello world');
<script>
tagconst createCommandQueueModule = require('command-queue-module');
const myTrackingLibrary = createCommandQueueModule(['trackEvent'], (onLoad) => {
const script = document.createElement('script');
script.src = 'https://example.org/my-tracking-library.umd.js';
script.onload = () => {
onLoad(window.MyTrackingLibrary)
};
document.body.append(script);
}));
// Works no matter if library is already loaded or not
myTrackingLibrary.trackEvent('Hello world');
FAQs
Create command queue proxies for modules
We found that command-queue-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.