Skip to content

Instantly share code, notes, and snippets.

@hizo
Created December 29, 2016 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hizo/6cd828100c7d89a4bfae1227d28a3ca5 to your computer and use it in GitHub Desktop.
Save hizo/6cd828100c7d89a4bfae1227d28a3ca5 to your computer and use it in GitHub Desktop.
Script loading
var scripts = ['app.a700a9a3e91a84de5dc0.js']; // script for all users
var newBrowser = (
'fetch' in window &&
'Promise' in window &&
'assign' in Object &&
'keys' in Object
);
if (!newBrowser) {
scripts.unshift('polyfills.a700a9a3e91a84de5dc0.js'); // script for the less fortunate
}
scripts.forEach(function(src) {
var scriptEl = document.createElement('script');
scriptEl.src = src;
scriptEl.async = false;
document.head.appendChild(scriptEl);
});
// ...
// webpack.config.js
config.entry = {
app: [
path.resolve(__dirname, `../app/client/client.jsx`),
],
polyfills: [
`babel-polyfill`,
`whatwg-fetch`,
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment