Switch inline code to js