From 2d32b5d1b663fa331ec256b73e937af15eb6e3d5 Mon Sep 17 00:00:00 2001 From: Mark Brouch Date: Tue, 10 Oct 2017 10:06:47 -0500 Subject: [PATCH] feat(ssr): auto-remove initial state script if prod (#6763) close #6761 --- src/server/template-renderer/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/server/template-renderer/index.js b/src/server/template-renderer/index.js index 48aa0caa..680e1713 100644 --- a/src/server/template-renderer/index.js +++ b/src/server/template-renderer/index.js @@ -191,10 +191,13 @@ export default class TemplateRenderer { contextKey = 'state', windowKey = '__INITIAL_STATE__' } = options || {} + const autoRemove = process.env.NODE_ENV === 'production' + ? '(function(){var s;(s=document.currentScript||document.scripts[document.scripts.length-1]).parentNode.removeChild(s);}());' + : '' return context[contextKey] ? `` + }${autoRemove}` : '' }