How to use size() function on external canvas

I currently want to use the size() method on an external canvas, but I’m worried the size function will change the CSS W/H instead of the W/H attribute itself.

almost like this:

webglCanvas = select('#mainViewport');
webglCanvasSize = webglCanvas.size(500, 500);