clearwater
clearwater copied to clipboard
Remove sanity checks during render in production
I found this tweet that explains how to detect if your code is minified.
kentcdodds Yes. This expression is true if minified, false if not. Props to RactiveJS for this approach.
!/x/.test(function(){/x/});
(@ symbols removed from tweet text so GitHub doesn't notify those mentioned)
I'd been looking for ways to add a flag to give warnings in dev but not in production (things like "you provided both class
and class_name
properties for this element) for performance reasons and you don't want to show users your dev warnings. Since Opal doesn't seem to have anything built in that allows selective compilation for different environments, this might be a decent way to go.
An alternative is to move files around during a rake assets:precompile
or something, but that would complicate the build process. So far, the minification detection seems like the best turnkey solution for the moment.