From ea64351f526367387eec630dd933d311d2d6d58c Mon Sep 17 00:00:00 2001
From: Kushagra Gour <chinchang457@gmail.com>
Date: Sun, 12 Aug 2018 17:50:27 +0530
Subject: [PATCH] app: throttle codesize calculation

---
 src/components/app.jsx | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/components/app.jsx b/src/components/app.jsx
index 042e6e2..52315e5 100644
--- a/src/components/app.jsx
+++ b/src/components/app.jsx
@@ -701,7 +701,14 @@ export default class App extends Component {
 			}
 		}
 		if (this.state.prefs.isJs13kModeOn) {
-			this.calculateCodeSize();
+			// Throttling codesize calculation
+			if (this.codeSizeCalculationTimeout) {
+				clearTimeout(this.codeSizeCalculationTimeout);
+			}
+			this.codeSizeCalculationTimeout = setTimeout(() => {
+				this.calculateCodeSize();
+				this.codeSizeCalculationTimeout = null;
+			}, 1000);
 		}
 	}
 	onCodeSettingsChange(type, settings) {