Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
vue-plugin-load-script
Advanced tools
A Vue plugin for injecting remote scripts.
Compatible with Vue 3.
For Vue 2, see the master branch.
# npm
npm install --save vue-plugin-load-script@^2.x.x
# yarn
yarn add vue-plugin-load-script@^2.x.x
If you're using the Options API:
// main.js
import { createApp } from "vue";
import LoadScript from "vue-plugin-load-script";
const app = createApp(App);
app.use(LoadScript);
app.mount("#app");
// Composition API
import { loadScript } from "vue-plugin-load-script";
loadScript("https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY")
.then(() => {
// Script is loaded, do something
})
.catch(() => {
// Failed to fetch script
});
// Options API
this.$loadScript("https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY")
.then(() => {
// Script is loaded, do something
})
.catch(() => {
// Failed to fetch script
});
If you'd like to remove (unload) the script at any point, then call the companion method unloadScript
/ this.$unloadScript
with the same URL.
// Composition API
import { unloadScript } from "vue-plugin-load-script";
unloadScript("https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY")
.then(() => {
// Script was unloaded successfully
})
.catch(() => {
// Script couldn't be found to unload; make sure it was loaded and that you passed the same URL
});
// Options API
this.$unloadScript("https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY")
.then(() => {
// Script was unloaded successfully
})
.catch(() => {
// Script couldn't be found to unload; make sure it was loaded and that you passed the same URL
});
In most situations, you can just call unloadScript
/ this.$unloadScript
and ignore the returned promise.
FAQs
A Vue plugin for injecting remote scripts
We found that vue-plugin-load-script 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
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.