Try document.querySelector(".loader").remove() document is referencing the whole page. querySelector gets the first element with the given attribute. remove() removes it.
document.querySelector(".loader").remove()
document
querySelector
remove()