safe js initialization