🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

webpack-plugin-forceinsertscripttag

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-plugin-forceinsertscripttag

webpack plugin forceinsertscripttag

Source
npmnpm
Version
1.1.12
Version published
Weekly downloads
61
-56.12%
Maintainers
1
Weekly downloads
 
Created
Source

forceInsertScriptTag

  • html-webpack-plugin 的 inject: true, 直接 根据参数 isInsertBody 决定插入到 head 还是 body 里面
  • 在 head | body 里面根据参数 isShift 决定是 前置插入还是后置插入
  • html-webpack-plugin 的 inject: false,只会插入在body 里面,但是可以根据参数 isShift 决定是 在body进行 前置插入还是 后置插入
  • 可以通过设置 jsDeferLoad | jsAsyncLoad 来决定
  • url 和 innerHTML 不可以同时设置,也不可以同时不设置 (两者总要设置一个)

Usage

const Forceinsertscripttag = require('webpack-plugin-forceinsertscripttag');

module.exports = {
    ...
    plugins: [
        ...
        new Forceinsertscripttag({
            isShift: true, // default: true 前置插入 还是 后置插入
            isInsertBody: true, //default: true  插入的 head 里面 还是 body 里面 (html-webpack-plugin 的 inject: false,只会插入在body 里面)
            url: 'xxx.js', // 被加载的 js 地址
            jsDeferLoad: false, // default: false  插入的 js 需不需要 在<script> 设置 defer 属性
            jsAsyncLoad: false, // default: false  插入的 js 需不需要 在<script> 设置 async 属性
            innerHTML: 'xx',
        }),
    ]
}

Keywords

webpack

FAQs

Package last updated on 19 Jun 2024

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