Only require selector/_loader when DOM present. Fixes #17138.
(cherry picked from commit f8c0a982ec0ba4debb21713a27732fcfafb527f1)