ru

require-unpkg

require from unpkg.com in browser

Showing:

Popularity

Downloads/wk

15

GitHub Stars

5

Maintenance

Last Commit

4yrs ago

Contributors

3

Package

Dependencies

0

Size (min+gzip)

0.7KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

require-unpkg

Greenkeeper badge

Build Status

require from unpkg.com in browser

Example

Example(codepen)

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">

  <script src="dist/require.js"></script>
  <!--cdn-->
  <!--script src="https://unpkg.com/require-unpkg"></script-->
  <title>Example</title>
</head>

<body>
  <div id="jquery"></div>
  <div id="vue">
    <input type="text" v-model="input">
  </div>
  <script>
    require.cache.expire = 100000; //set cache time (DONT SET TO 0), default: 24 hours

    //with es7 async/await:
    (async function () {
      let $ = await require('jquery')
      $('#jquery').text('jquery hello world')
    })()

    //with Promise+Array Destructuring:
    require(['vue','vuejs-storage']).then(([Vue,vuejsStorage]) => {
      Vue.use(vuejsStorage)
      new Vue({
        el: '#vue',
        storage: {
          data: {
            input: ''
          },
          namespace: 'test'
        }
      })
    })
  </script>
</body>

</html>

Extra

_require

require._require only require single module only ex: require._require('jquery')

_get

require._get provide simple xhr GET function ex:require._get(url)

node.js

To use in node.js environment, you must set

const urequire = require('unpkg-require')
urequire.XMLHttpRequest = XHR_POLYFILL //like xhr2...

urequire('lodash').then(_ => {})

But I don't know why to require unpkg instead of node_modules

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100