My 2 cents tips to avoid all the extra code generated by Sketch is to install a plugin called SVGO Compressor that removes all the non necessary elements, attributes and comments not needed for the SVG file to work correctly.
It’s developed by Bohemian Code, so is super-safe: https://github.com/BohemianCoding/svgo-compressor