Improved registration of javascript on frontend