How to enqueue assets only on queried pages, excluding the page being queried?

NOTE: This code is correct above is the solution I was looking for.

I just overlooked applying it to some scripts and so I thought it wasn’t working.