Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-script2

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-script2 - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

24

dist/vue-script2.js
/*!
* vue-script2 v1.2.0
* vue-script2 v1.2.1
* (c) 2016 Greg Slepak

@@ -12,11 +12,6 @@ * @license MIT License

// To use, just:
//
// 1. search-replace "<script " with "<script2 "
// 2. search-replace "</script>" with "</script2>"
var Script2 = {
installed: false,
p: Promise.resolve(),
version: '1.2.0', // grunt will over write to match package.json
version: '1.2.1', // grunt will overwrite to match package.json
loaded: {}, // keys are the scripts that have been loaded

@@ -72,6 +67,3 @@ install: function install(Vue) {

if (Script2.loaded[src]) return Promise.resolve(src);
return new Promise(function (resolve, reject) {
var _this2 = this;
return Script2.loaded[src] ? Promise.resolve(src) : new Promise(function (resolve, reject) {
var s = document.createElement('script');

@@ -88,9 +80,7 @@ // omit the special options that Script2 supports

// and: https://github.com/ded/script.js/blob/master/src/script.js#L70-L82
function success() {
s.onload = function () {
Script2.loaded[src] = 1;resolve(src);
}
s.onload = success;
s.onreadystatechange = function () {
return _this2.readyState === 'complete' && success();
}; // IE
};
// IE should now support onerror and onload. If necessary, take a look
// at this to add older IE support: http://stackoverflow.com/a/4845802/1781435
s.onerror = function () {

@@ -97,0 +87,0 @@ return reject(new Error(src));

/*!
* vue-script2 v1.2.0
* vue-script2 v1.2.1
* (c) 2016 Greg Slepak
* @license MIT License
*/
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.VueScript2=n()}(this,function(){"use strict";var e={installed:!1,p:Promise.resolve(),version:"1.2.0",loaded:{},install:function(t){arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(!e.installed){var i=["unload"],o=i.concat(["src","type","async","integrity","text","crossorigin"]);t.component("script2",{props:o,template:'<div style="display:none"><slot></slot></div>',ready:function(){var i=this,r=this.$el.parentElement;if(this.src){var a=n.omitBy(n.pick(this,o),n.isUndefined);a.parent=r;var c=function(){return e.load(i.src,a)};n.isUndefined(this.async)?e.p=e.p.then(c):c()}else e.p=e.p.then(function(){var e=document.createElement("script");e.type="text/javascript",e.appendChild(document.createTextNode(i.$el.innerHTML)),r.appendChild(e)});t.util.remove(this.$el)},destroyed:function(){this.unload&&(new Function(this.unload)(),delete e.loaded[this.src])}}),e.installed=!0}},load:function(t){var i=arguments.length<=1||void 0===arguments[1]?{parent:document.head}:arguments[1];return e.loaded[t]?Promise.resolve(t):new Promise(function(o,r){function a(){e.loaded[t]=1,o(t)}var c=this,d=document.createElement("script");n.defaults2(d,n.omit(i,["unload","parent"]),{type:"text/javascript"}),d.async=!1,d.src=t,d.onload=a,d.onreadystatechange=function(){return"complete"===c.readyState&&a()},d.onerror=function(){return r(new Error(t))},i.parent.appendChild(d)})}},n={isUndefined:function(e){return void 0===e},pick:function(e,n){var t={};return n.forEach(function(n){return t[n]=e[n]}),t},omit:function(e,n){var t={};return Object.keys(e).forEach(function(i){-1===n.indexOf(i)&&(t[i]=e[i])}),t},omitBy:function(e,n){var t={};return Object.keys(e).forEach(function(i){n(e[i])||(t[i]=e[i])}),t},defaults2:function(e){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;t>o;o++)i[o-1]=arguments[o];i.forEach(function(t){Object.keys(t).forEach(function(i){(n.isUndefined(e[i])||""===e[i])&&(e[i]=t[i])})})}};return e});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.VueScript2=n()}(this,function(){"use strict";var e={installed:!1,p:Promise.resolve(),version:"1.2.1",loaded:{},install:function(t){arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(!e.installed){var i=["unload"],o=i.concat(["src","type","async","integrity","text","crossorigin"]);t.component("script2",{props:o,template:'<div style="display:none"><slot></slot></div>',ready:function(){var i=this,r=this.$el.parentElement;if(this.src){var c=n.omitBy(n.pick(this,o),n.isUndefined);c.parent=r;var a=function(){return e.load(i.src,c)};n.isUndefined(this.async)?e.p=e.p.then(a):a()}else e.p=e.p.then(function(){var e=document.createElement("script");e.type="text/javascript",e.appendChild(document.createTextNode(i.$el.innerHTML)),r.appendChild(e)});t.util.remove(this.$el)},destroyed:function(){this.unload&&(new Function(this.unload)(),delete e.loaded[this.src])}}),e.installed=!0}},load:function(t){var i=arguments.length<=1||void 0===arguments[1]?{parent:document.head}:arguments[1];return e.loaded[t]?Promise.resolve(t):new Promise(function(o,r){var c=document.createElement("script");n.defaults2(c,n.omit(i,["unload","parent"]),{type:"text/javascript"}),c.async=!1,c.src=t,c.onload=function(){e.loaded[t]=1,o(t)},c.onerror=function(){return r(new Error(t))},i.parent.appendChild(c)})}},n={isUndefined:function(e){return void 0===e},pick:function(e,n){var t={};return n.forEach(function(n){return t[n]=e[n]}),t},omit:function(e,n){var t={};return Object.keys(e).forEach(function(i){-1===n.indexOf(i)&&(t[i]=e[i])}),t},omitBy:function(e,n){var t={};return Object.keys(e).forEach(function(i){n(e[i])||(t[i]=e[i])}),t},defaults2:function(e){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;t>o;o++)i[o-1]=arguments[o];i.forEach(function(t){Object.keys(t).forEach(function(i){(n.isUndefined(e[i])||""===e[i])&&(e[i]=t[i])})})}};return e});
{
"name": "vue-script2",
"version": "1.2.0",
"version": "1.2.1",
"description": "Brings back <script> to your favorite Single Page App!",

@@ -5,0 +5,0 @@ "main": "dist/vue-script2.js",

@@ -5,3 +5,3 @@ # VueScript2 - Simple, Familiar Asynchronous Script Loading

This tiny library should take care of all your [declarative](#familiar-declarative-asynchronous-loading-of-scripts) and [imperative](#promise-based-imperative-loading-too) asynchronous loading needs. Web designers can rest easy that their existing knowledge of web development is still useful!
This tiny library should take care of all your [declarative](#familiar-declarative-asynchronous-loading-of-scripts) and [imperative](#promise-based-imperative-loading-too) asynchronous loading needs. Web designers can rest easy knowing their existing knowledge of web development is still useful!

@@ -23,3 +23,3 @@ This version is tailored for the [Vue.js](http://vuejs.org) framework, but it's easy to port to [Riot.js](http://riotjs.com) and others.

- Special [`unload` attribute](#cleanup-unused-resources-with-the-unload-attribute) can be used to keep your app's memory usage low!
- Does [imperative loading](#promise-based-imperative-loading-too) too, no need for RequireJS/SystemJS/etc.!
- Does [imperative loading](#promise-based-imperative-loading-too) too!

@@ -58,3 +58,3 @@ Oh, and it's easy to modify this library to also support imperative loading of

No need to bundle RequireJS/SystemJS or whatever else. Call `VueScript2.load` to immediately load a script.
Imperatively load scripts with `VueScript2.load`:

@@ -67,4 +67,6 @@ ```js

_All scripts injected using `VueScript2.load` are [`async`](#special-support-for-async-attribute)._
For 99% of use-cases this is totally sufficient and you do not need the overhead of RequireJS or SystemJS or whatever else. That's especially true given that Vue.js is normally used with Browserify or Webpack, which handle complicated dependency management for you.
_NOTE: scripts injected using `VueScript2.load` are always [`async`](#special-support-for-async-attribute)._
##### Delayed execution of inlined JavaScript

@@ -140,2 +142,3 @@

- __1.2.1__ - Just a bit of perfectionism to fix a non-issue issue
- __1.2.0__ - Added `VueScript2.load` imperative loading

@@ -142,0 +145,0 @@ - __1.1.2__ - Another bump to get npm.org to display `script2ify` in the README

@@ -1,10 +0,5 @@

// To use, just:
//
// 1. search-replace "<script " with "<script2 "
// 2. search-replace "</script>" with "</script2>"
var Script2 = {
installed: false,
p: Promise.resolve(),
version: '1.2.0', // grunt will over write to match package.json
version: '1.2.1', // grunt will overwrite to match package.json
loaded: {}, // keys are the scripts that have been loaded

@@ -53,4 +48,4 @@ install (Vue, options = {}) {

load (src, opts = {parent: document.head}) {
if (Script2.loaded[src]) return Promise.resolve(src)
return new Promise(function (resolve, reject) {
return Script2.loaded[src] ? Promise.resolve(src)
: new Promise(function (resolve, reject) {
var s = document.createElement('script')

@@ -67,5 +62,5 @@ // omit the special options that Script2 supports

// and: https://github.com/ded/script.js/blob/master/src/script.js#L70-L82
function success () { Script2.loaded[src] = 1; resolve(src) }
s.onload = success
s.onreadystatechange = () => this.readyState === 'complete' && success() // IE
s.onload = () => { Script2.loaded[src] = 1; resolve(src) }
// IE should now support onerror and onload. If necessary, take a look
// at this to add older IE support: http://stackoverflow.com/a/4845802/1781435
s.onerror = () => reject(new Error(src))

@@ -72,0 +67,0 @@ opts.parent.appendChild(s)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc