Fix files external flickering

forward port of https://github.com/owncloud/core/pull/11550 with additional js cleanups for master
@PVince81 @blizzz