1.0.0 • Published 7 years ago

eval-script v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

#eval-script

it is written in ES6, tested with karma, mocha, chai with the similar functionality with simple-load-script

Installation

###npm

npm install --save-dev eval-script

###Yarn

yarn add --dev eval-script

Usage(UMD)

in ES6

import evalScript from 'eval-script'

evalScript('http://code.jquery.com/jquery-2.2.3.js',{
      'id':'script-jquery',
      'async':true
    },
    callback
  )
  .then(() => console.log("success"))
  .catch(error => console.log(error))

  const callback = () => console.log("call me after script was loaded")

in Browser

<script src='https://dl.dropboxusercontent.com/u/144131307/index.min.js'> </script>
<script type="text/javascript">
evalScript('http://code.jquery.com/jquery-2.2.3.js',{
      'id':'script-jquery',
      'async':true
    },
    callback
  ).then(function(){console.log("success");})
  .catch(function(error){console.log(error);});
function callback(){
  console.log("call me after script was loaded");
}

</script>

###Common Js

var evalScript = require('eval-script');
evalScript(url, options, callback)

test

  npm t