How can I reliably run a jquery script after page load
<p>I'm attempting to get some jquery code to run after a sharepoint page loads, the code being:</p>

<pre><code>$(".ms-commentcollapse-icon").click();
</code></pre>

<p>I've been using the following to load the code after the page loads, but it does not seem to be very reliable (it will work sometimes and other times it wont):</p>

<pre><code>&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
$(window).load(function () {
        $(".ms-commentcollapse-icon").click();
});
&lt;/script&gt;
</code></pre>

<p>are there any other good methods for achieving this? I'm not sure what's going on, sharepoint could be at fault, but I figured I would try fiddling around with the script a bit more first. </p>