You said you're using an iPad. So unless you've jailbroken your device, there is no malware on it. None.
What you're seeing is a simple JavaScript action. As has been true of web browsers since almost the beginning is they store data of the sites you visit in a cache on your device. It's there so the next time you go to a previously visited site, it can pull most of the elements from your local cache rather than from the remote server every single time. This speeds up the overall experience, which is the entire point of the cache's existence.
The cache contains JavaScript code that is saved with the rest of the cached items. Once collected from a site that runs these ads, simply by being there, it runs in a persistent state, calling on the same ad server. You clear the cache, it's gone. You use the Internet again where the same JavaScript action is, it gets saved to the cache again and you start all over.
JavaScript isn't malware. It's how much of the web works. You can turn it off and that will stop any ads that use JavaScript to push them in your face, but then most of the web also won't function as you expect.
Using an ad blocker stops the ads from being sent to your device in the first place. This also prevents the JavaScript action from running and being saved to the cache.
Also, making even mild threats are very much frowned upon by the hosts. You'll find yourself banned if you keep that up.