js fit window to content

JavaScript
/* fit the window size to match the content wrapper */
function fitWindow2Content( contentWrapper ) {
  
	// calculate necessary change in window's width
	var width = window.innerWidth - contentWrapper.clientWidth;

	// calculate necessary change in window's height
	var height = window.innerHeight- contentWrapper.clientHeight;
  
  	// resize window to fit content
	window.resizeBy( -width , -height );

}
Source

Also in JavaScript: