Hi, and thanks for attempting a time sync library for javascript. It seems you are trying to attempt what NTP does, but of course there is no NTP client for javascript that would work in a browser because it has it's own TCP protocol.
But basically, NTP is about measuring the roundtrip time and adjusting the results accordingly, so I find this very similar.
The problem is that you are determining the offset by subtracting the entire round trip time from the server time. But if you think about it, the server took its timestamp somewhere approximately half-way along the the trip. At minimum, you should divide by 2 so you are only accounting for the return-leg of the trip.
Simple division doesn't take into account asymmetric connections though. Most users have a faster download than upload, so 2 may be too large of a divisor. Determining the right value can be very tricky.
NTP works so well because they make several samples, not just one. And both the client and the server are each adjusting sending their time to the other until consensus is reached within a particular threshold. That way, it can measure each leg of the trip separately (sort of).
Not sure if you want to do anything about this in your library or not, but I thought I would at least point it out.