Issue #3239136 by hooroomoo, ahsannazir, smustgrave: Refactor (if feasible) uses of the jQuery when function to use vanillaJS