Use wfAppendQuery() instead of "$path?$wgStyleVersion" where $path can contain ?foo...