you don't need to detach\attach the database to shrink it.
you can backup and restore the database without affecting replication as long as replication is quiesced (stop all the replication agents)
---------------------------------------------------------------------