[JS] - replace loading script with closure