
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
webworker-preload
Advanced tools
Web Worker based preloading of website resources such as javascript. Allows for delayed execution of javascript and enhanced above the fold optimization.
webworker-preload is a tool intended for advanced optimization purposes. It allows for preloading of resources such as javascript, CSS and image files using Web Workers. Preloading resources using web workers has several advantages for optimization, it is non-blocking (it utilizes resources from CPU's not used for rendering) and it allows for delayed execution of javascript.
The size is <4kb.
The tool consists of the method window.preloadww that will accept an array with resources to preload. The array should consist of URL's and optionally a resource specific callback. Instead of entering URI strings it is possible to provide an array with configuration objects.
The preloadww method accepts an onLoad callback and an onError callback. The onLoad callback is always called upon completion, also when (some) files are on error.
The onLoad method will resolve with an array with URI's that have been preloaded.
// simple array with string URI's to preload
window.preloadww(['/css/file1.css','/js/scripts.js','/js/mobile.js'], function onLoad(fileList) {
console.info('preload completed',fileList);
},function onError(error) {
console.error('preload failed',error);
});
// resource specific onload callback for script file
window.preloadww(['/css/file1.css',['/js/scripts.js', function scriptLoaded(status) {
if (status === 'ok') {
// execute javascript in container
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '/js/script.js';
document.getElementById('container').appendChild(script);
} else if (status === 'error') {
console.error('failed to preload script');
}
}],'/js/mobile.js'], function onLoad(fileList) {
console.info('preload completed',fileList);
},function onError(error) {
console.error('preload failed',error);
});
// object based resource list
window.preloadww([{uri:'/css/file1.css'},{uri: '/js/scripts.js', callback: function scriptLoaded(status) {
if (status === 'ok') {
// execute javascript in container
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '/js/script.js';
document.getElementById('container').appendChild(script);
} else if (status === 'error') {
console.error('failed to preload script');
}
}},{uri:'/js/mobile.js'}], function onLoad(fileList) {
console.info('preload completed',fileList);
},function onError(error) {
console.error('preload failed',error);
});
npm install --save webworker-preload
The following article from Matt Seeley provided inspiration for this tool.
https://gist.github.com/mseeley/9321422
This library is published under the MIT license. See LICENSE for details.
FAQs
Web Worker based preloading of website resources such as javascript. Allows for delayed execution of javascript and enhanced above the fold optimization.
We found that webworker-preload 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.