
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
A lightweight library to asynchronously load scripts on the fly.
# Using npm
$ npm install get-js --save
# Using Yarn
$ yarn add get-js
# Using Bower
$ bower install get-js --save
For older browsers you may also need a promise polyfill.
# Install promise polyfill.
$ npm install es6-promise
Use it in your project with require
or import
as an ES module.
var get = require('get-js');
// ES2015+
import get from 'get-js';
Or, using <script>
tags:
<script type="text/javascript" src="https://unpkg.com/get-js@0.0.7/dist/get.min.js"></script>
Here you go:
// Load a single script
get('https://code.jquery.com/jquery-2.2.3.min.js').then(function() {
console.log('do something');
});
// Load multiple scripts, without changing the order
get(['/js/abc.js', '/js/xyz.js'])
.then(function() {
console.log('do something now');
})
.catch(function() {
console.log('error');
});
Note: This refers to angular 1.x projects.
You can inject this in your angular code as a service.
Require the angular module using
var angularGetJs = require('get-js/angular');
Or
<script type="text/javascript" src="https://unpkg.com/get-js@0.0.7/dist/angular-get.min.js"></script>
Then you should be able to use it like this:
// Add the module as a dependency in your app.
angular.module('app', ['angularGetJs']);
// Inject the service
angular.module('app').controller('MyController', [
'get',
function(get) {
get('/some/script.js')
.then(function() {
console.log('do something now');
})
.catch(function() {
console.log('error');
});
}
]);
This package is licensed under the MIT License.
FAQs
A lightweight library to asynchronously load scripts on the fly.
The npm package get-js receives a total of 125 weekly downloads. As such, get-js popularity was classified as not popular.
We found that get-js 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.