Gathering detailed insights and metrics for vue-scriptx
Gathering detailed insights and metrics for vue-scriptx
Gathering detailed insights and metrics for vue-scriptx
Gathering detailed insights and metrics for vue-scriptx
npm install vue-scriptx
Typescript
Module System
Node Version
NPM Version
70.4
Supply Chain
98.2
Quality
76.5
Maintenance
100
Vulnerability
100
License
TypeScript (93.54%)
JavaScript (6.46%)
Total Downloads
83,978
Last Day
43
Last Week
494
Last Month
3,030
Last Year
71,870
10 Stars
15 Commits
2 Forks
1 Watching
1 Branches
2 Contributors
Latest Version
0.2.7
Package Id
vue-scriptx@0.2.7
Unpacked Size
11.65 kB
Size
4.66 kB
File Count
9
NPM Version
9.8.1
Node Version
18.18.0
Publised On
21 Oct 2024
Cumulative downloads
Total Downloads
Last day
-41.9%
43
Compared to previous day
Last week
-21%
494
Compared to previous week
Last month
-8.2%
3,030
Compared to previous month
Last year
764.1%
71,870
Compared to previous year
2
VueScriptX brings back the <script>
tag to your Vue projects!
This package is inspired by vue-script2.
This tiny package should take care of all your declarative and imperative asynchronous loading needs. Nothing too complicated from what web devs already know.
This version is tailored for the Vue.js framework, but it's easy to port to others.
If you like this package, a star to the repo is nice.
<script>
tag to your Vue projects as <scriptx>
.$scriptx
for regular code access.async
prop.unload
handles callbacks after script being unmounted.npm install vue-scriptx --save
Then enable the plugin (in your main.ts
or wherever):
1import App from '../App.vue' 2import ScriptX from 'vue-scriptx' 3 4createApp(App) 5.use(ScriptX) 6
As simple as using <scriptx>
as <script>
tags or using this.$scriptx
, below samples illustrates how to load jQuery asynchronously.
DO NOT put user provided code inside <scriptx>
or its propeties.
By default, <scriptx>
tags are serialized using promises so that one script loads after another has finished. If you don't need ordered execution, add async
to have the script injected immediately.
The scriptx
component takes text as slot, you can still use delimiters to change the text being sent as slot.
1<scriptx src="/path/to/jquery.min.js"></scriptx> 2<scriptx> 3 $('#msg').text('Hello from VueScriptX!') 4</scriptx>
async
Specify if this script should load itself asynchronously (ignoring execution order of other scripts). This defaults to "false"
.
You can also mix them so that some <scriptx>
tags are loaded asynchronously while others wait for the ones before them.
1<scriptx src="jquery.min.js"></scriptx> 2<scriptx>$('#foo').text('hi!')</scriptx> 3<!-- Load next script immediately, don't wait for jQuery --> 4<scriptx src="lib.js" async></scriptx>
unload
Callback being executed after the scriptx is being unmounted. Note that it takes a string containing the code.
1<scriptx src="/path/to/jquery.min.js" unload="jQuery.noConflict(true)"></scriptx>
It may not work in typescript as it may complain that $
is undefined.
1this.$scriptx.load('/path/to/jquery.min.js') 2.then(() => $('#msg').text('Hello from VueScriptX!'))
Contributions are welcomed, as long as it doesn't cause any harm to any users.
Please do not submit compiled files (e.g. the dist
directory of this repo).
No vulnerabilities found.
No security vulnerabilities found.