canvas javascript build and structure