Moving script enqueue to function from template