I agree that Jon faced a lot tougher competition. The OP was "Who came closer to getting Rocked?" That answer is clearly Jon.
The Gus fight was Jon's 20th pro fight at age 26. By Khabib's 20th fight which was the same year he was 25 (1 year younger then Jon) and had not lost a round and almost literally had not been hit. Jon at LHW was very similar to Khabib in that both were dominant, both retired in 2020 and vacated the title. Jon was not as dominant as Khabib but fought a higher level of compeition. Khabib barely ever got hit and never came close to losing. Jon got hospitalized by Gus, had to cheat against Matt Hamill, Anthony Smith in order to get a finish (should have been 2 DQs) plus his NC against DC so really should be 3 DQ's. Had a close SD against Santos and lost to Reyes in his final fight. At the same age Jon had 28 pro fights and Khabib had 29. Jon struggled in his last 3 LHW fights while Khabib smashed his last 3 with finishes.
For all we know if Khabib had been pushed into a title fight at 23 he could have been smashed. But its more probable he would have dominated. Remember that half of Jon's defenses were opponents that fought as MWs. Hendo who was booked vs Jon + Chael, Vitor, Lyoto, Rashad, Smith, Santos all fought at MW. So add 6 FWs to Khabib's title run. Florian, Ancient BJ Penn, Frankie, Max. Do any of those guys beat Khabib??? Not likely.