Sorry I had to be clearer about the diff. This diff is from the commit that introduced the malicious code. It was part of a feature branch (https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow) that he was working on about some frontend and SEO stuff. Actually the changes that the whole branch introduced are a lot more than the changes depicted in this diff.
Yeah, that's the only reasonable explanation I could think of too.