Instead of executing the function (and passing the result) :
window.addEventListener('load', setSize(), false);
window.addEventListener('resize', setSize(), false);
you should pass a reference to the function:
window.addEventListener('load', setSize, false);
window.addEventListener('resize', setSize, false);
The function will execute when the event listener triggers.