Why not just pageYoffset without testing scrollY ? Both properties are described in CSSOM spec.