I found a possible solution! Instead of defining a class as .klass in the KSS, rather do img.klass or whatever tag is relevant. This drops the number of Javascript calls by 1082 for me.