Socket
Socket
Sign inDemoInstall

wishy

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wishy

Simplistic dynamic script loader for non-modules.


Version published
Maintainers
1
Created
Source

Wishy

Wishy allows you to dynamically import scripts, adding them as <script> tags in the DOM. Its name comes from wishy-washy, meaning indecisive.

Why?

You could and should use dynamic import() to load ES6 modules, but unfortunately not all things are written that way. Wishy allow you to import simple scripts.

How to use it

Just call the wish function with a list of paths to the scripts you want to import. You can also put in an object and wishy will interpret key/vales as attributes. The <script> tags are added to a <div> with class "_wishywashy". For example:

wish([
  "path1",
  {
    "src": "path2"
    "key": "value"
  }
  ])

is rendered in the DOM as

<div class="_wishywashy">
  <script src="path1"></script>
  <script src="path2" key="value"></script>
</div>

You can remove all <script> tags from the DOM with the wash() function, but that won't remove them from memory.

How to install it

Just plain import the script. It'll create a function called "wish()" to which you pass your script paths and a "wash()" to remove them.

Caveats

Note that any script loaded by wishy is deferred and won't be executed synchronously. Wish is written in ES6. Calling wish() inside a module script won't work.

Keywords

FAQs

Package last updated on 17 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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