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
TypeScript (93.54%)
JavaScript (6.46%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
10 Stars
15 Commits
1 Forks
1 Watchers
1 Branches
2 Contributors
Updated on Dec 15, 2024
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
Published on
Oct 21, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
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.