Skip to content

Commit 9345cfa

Browse files
committed
added defer attribute to scripts
1 parent b7a0757 commit 9345cfa

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/react-scripts/config/webpack.config.prod.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const fs = require('fs');
1616
const webpack = require('webpack');
1717
const NameAllModulesPlugin = require('name-all-modules-plugin');
1818
const HtmlWebpackPlugin = require('html-webpack-plugin');
19+
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
1920
const ExtractTextPlugin = require('extract-text-webpack-plugin');
2021
const ManifestPlugin = require('webpack-manifest-plugin');
2122
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
@@ -322,6 +323,11 @@ module.exports = {
322323
minifyURLs: true,
323324
},
324325
}),
326+
// This ensures that the browser will load the scripts in parallel,
327+
// but execute them in the order they appear in the document.
328+
new ScriptExtHtmlWebpackPlugin({
329+
defaultAttribute: 'defer',
330+
}),
325331
// Makes some environment variables available to the JS code, for example:
326332
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
327333
// It is absolutely essential that NODE_ENV was set to production here.

packages/react-scripts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"promise": "7.1.1",
5454
"react-dev-utils": "^1.0.3",
5555
"react-error-overlay": "^1.0.3",
56+
"script-ext-html-webpack-plugin": "^1.8.0",
5657
"style-loader": "0.17.0",
5758
"sw-precache-webpack-plugin": "0.9.1",
5859
"url-loader": "0.5.8",

0 commit comments

Comments
 (0)