common tool functions for javascript in browser