{"id":19427,"library":"crossorigin-webpack-plugin","title":"crossorigin-webpack-plugin","description":"Webpack plugin to add `crossorigin` attribute to script tags generated by html-webpack-plugin. Supports webpack v2–v5 and html-webpack-plugin v2–v5. Zero-config, defaults to `anonymous`. Lightweight alternative to manually editing templates or using HtmlWebpackPlugin hooks. Stable release 1.0.0 with no further updates since 2018.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/wannaxiao/crossorigin-webpack-plugin","tags":["javascript","webpack-plugin","webpack","crossorigin","html"],"install":[{"cmd":"npm install crossorigin-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add crossorigin-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add crossorigin-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"The plugin modifies script tags generated by html-webpack-plugin; must be placed after it in plugins array.","package":"html-webpack-plugin","optional":false}],"imports":[{"note":"Package does not ship ESM; CommonJS require is required.","wrong":"import CrossoriginWebpackPlugin from 'crossorigin-webpack-plugin'","symbol":"CrossoriginWebpackPlugin","correct":"const CrossoriginWebpackPlugin = require('crossorigin-webpack-plugin')"},{"note":"Option key is 'crossorigin', not 'credentials'.","wrong":"new CrossoriginWebpackPlugin({ crossorigin: 'use-credentials' })","symbol":"CrossoriginWebpackPlugin","correct":"new CrossoriginWebpackPlugin()"},{"note":"Must be placed after HtmlWebpackPlugin in plugins array.","wrong":"plugins: [new CrossoriginWebpackPlugin(), new HtmlWebpackPlugin()]","symbol":"CrossoriginWebpackPlugin","correct":"plugins: [new HtmlWebpackPlugin(), new CrossoriginWebpackPlugin()]"}],"quickstart":{"code":"// webpack.config.js\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst CrossoriginWebpackPlugin = require('crossorigin-webpack-plugin');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: { path: __dirname + '/dist', filename: 'bundle.js' },\n  plugins: [\n    new HtmlWebpackPlugin({ template: './src/index.html' }),\n    new CrossoriginWebpackPlugin(), // defaults to anonymous\n    // or with custom: new CrossoriginWebpackPlugin({ crossorigin: 'use-credentials' })\n  ]\n};","lang":"javascript","description":"Adds crossorigin='anonymous' to all script tags in HTML output via html-webpack-plugin. Requires CommonJS require, plugin order matters."},"warnings":[{"fix":"Ensure HtmlWebpackPlugin instance comes before CrossoriginWebpackPlugin in the plugins array.","message":"Plugin must be placed after HtmlWebpackPlugin in the plugins array; otherwise it won't find script tags to modify.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use 'crossorigin' (lowercase) as the property name.","message":"Option 'crossorigin' is misspelled as 'crossorigin' (correct spelling: crossorigin). Using 'crossorigin' will be ignored silently in future versions.","severity":"deprecated","affected_versions":"1.0.0"},{"fix":"Use CommonJS require: const CrossoriginWebpackPlugin = require('crossorigin-webpack-plugin');","message":"Plugin does not support ES module imports; importing with ES6 'import' will fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Check version compatibility with your html-webpack-plugin; pin to known working versions.","message":"This plugin works only with html-webpack-plugin v2/v3/v4/v5; newer versions may break compatibility.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For other elements, manually modify template or use HtmlWebpackPlugin hooks.","message":"Plugin only adds attribute to <script> tags; does not affect <link> tags for preloads or other elements.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Replace 'import CrossoriginWebpackPlugin from ...' with 'const CrossoriginWebpackPlugin = require('crossorigin-webpack-plugin');'","cause":"Using ES6 import instead of CommonJS require.","error":"TypeError: CrossoriginWebpackPlugin is not a constructor"},{"fix":"Reorder plugins: place HtmlWebpackPlugin before CrossoriginWebpackPlugin.","cause":"CrossoriginWebpackPlugin placed before HtmlWebpackPlugin in plugins array.","error":"Error: Plugin could not find any script tags to process. Ensure HtmlWebpackPlugin is placed before this plugin."},{"fix":"Run 'npm install --save-dev crossorigin-webpack-plugin' or 'yarn add -D crossorigin-webpack-plugin'.","cause":"Package not installed or missing from package.json.","error":"Module not found: Error: Can't resolve 'crossorigin-webpack-plugin'"},{"fix":"Install and add HtmlWebpackPlugin to plugins array before CrossoriginWebpackPlugin.","cause":"Using plugin in webpack config without required html-webpack-plugin.","error":"Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}