JS detect the width of the screen, running a different JS files
<p>I write two js code. I want first detect the width of the screen, then run a different JS files. How to write correctly?</p>

<pre><code>$(document).ready(function() {

if ((screen.width&gt;=1024) &amp;&amp; (screen.height&gt;=768)) 
{ 
    $("link[text/javascript]:not(:first)").attr({src : "1024.js"}); 
} 
else 
{ 
    $("link[text/javascript]:not(:first)").attr({src : "768.js"}); 
} 
});
&lt;script src="1024.js"&gt;&lt;/script&gt;
&lt;script src="768.js"&gt;&lt;/script&gt;
</code></pre>
