New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

loadjs

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loadjs

Tiny async loader for modern browsers

4.3.0
latest
Source
npm
Version published
Weekly downloads
233K
-2.32%
Maintainers
1
Weekly downloads
 
Created

What is loadjs?

loadjs is a JavaScript library for dynamically loading JavaScript and CSS files. It provides a simple API for loading scripts and stylesheets asynchronously, with support for callbacks and error handling.

What are loadjs's main functionalities?

Loading a single JavaScript file

This feature allows you to load a single JavaScript file asynchronously. The callback function is executed once the script is successfully loaded.

loadjs('path/to/script.js', function() { console.log('Script loaded!'); });

Loading multiple JavaScript files

This feature allows you to load multiple JavaScript files asynchronously. The callback function is executed once all the scripts are successfully loaded.

loadjs(['path/to/script1.js', 'path/to/script2.js'], function() { console.log('Scripts loaded!'); });

Loading CSS files

This feature allows you to load a CSS file asynchronously. You can provide success and error callbacks to handle the loading status.

loadjs('path/to/styles.css', { success: function() { console.log('CSS loaded!'); }, error: function(pathsNotFound) { console.log('CSS failed to load: ' + pathsNotFound); } });

Named bundles

This feature allows you to group multiple files into a named bundle. You can then use the `loadjs.ready` method to execute a callback once the entire bundle is loaded.

loadjs(['path/to/script1.js', 'path/to/script2.js'], 'bundleName'); loadjs.ready('bundleName', function() { console.log('Bundle loaded!'); });

Error handling

This feature provides error handling for loading scripts. You can specify a callback function to handle cases where one or more scripts fail to load.

loadjs(['path/to/script1.js', 'path/to/nonexistent.js'], { success: function() { console.log('Scripts loaded!'); }, error: function(pathsNotFound) { console.log('Scripts failed to load: ' + pathsNotFound); } });

Other packages similar to loadjs

Keywords

async

FAQs

Package last updated on 11 Apr 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