New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

retry-script

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

retry-script

重试script

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

retry-script

retry-script插件是一款能够使我们的项目、在加载js静态资源失败的时候、进行重新尝试加载(或者换域名重新加载)

特色功能:

  • 使用简单、支持自定义配置
  • 支持cdn的方式引入

快速开始

引入script (注意: 一定要在项目的最顶部引入)

<script src="http://xxx.xxx.xxx/retry-script.js"></script>
<script>
new RetryScript([
    'http://local/1',
    'http://local/2',
    'http://local/3'
 ])
</script>

注意: 一定要在项目的最顶部引入

配置项

支持两种方式配置

  • 1、仅配置hosts时, 可以简化为

    new RetryScript([
        'http://local/1',
        'http://local/2',
        'http://local/3'
     ])
    
  • 2、当多个配置时,看下面示例

    new RetryScript({
        hosts: [
            'http://local/1',
            'http://local/2',
            'http://local/3'
        ],
        handler (config) {
            return config.join('http://www.xxx.cn', config.source)
        }
    })
    
名称类型默认值必传说明
hostsstring[]重试的host数组列表, 当js加载失败时、默认会依次从hosts数组中按照顺序取出对应的域名来尝试加载js
handlerfunction处理函数, 接收**config对象**, 返回值作为下次重试的src 地址; 如果返回值是字符串,则作为下次重试的src地址; 返回值如果是其他类型,则使用默认规则生成下次重试地址

config对象说明

名称类型说明
currentIndexnumber重试的hosts的index索引
sourcestring解析出来的资源名
oldSrcstring上一次加载失败的src路径
hostsstring[]传入的配置项hosts
joinfunction路径拼接函数、用法同nodepath模块的join方法

方法

方法名返回值示例描述
destorycaptcha.destory()销毁控件

Keywords

FAQs

Package last updated on 25 Mar 2023

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