Small JS refactoring
Make flakey popup work with Turbolinks