All our new code like $PAGE->requires->data_for_js and ->js_function_call automatically does json_encode on data, which is better than addslashes_js.
A quiz grep finds about 50 references in HEAD. We need to
1. Eliminate all calls in core.
2. Move it to deprecatedlib.php and add debugging output.