[jQuery] Loading jquery after page load
Is it possible to only load jquery after all other elements on the page have
loaded? I'm just using jquery to enhance my site which works perfectly fine
without javascript, that's why it doesn't matter to me that jquery is
available immediately.
I've noticed that some browsers show a white page until all javascript files
have been loaded (firefox)
I'm thinking it should be done like this:
$(document).ready(function() {
var s = document.createElement('script');
s.src = 'http://www.example.com/jquery.js';
$('#addScriptHere').append(s);
});
I would just use this code on first pageview (checking a cookie to see if
visitor has already visited, and thus has jquery.js in cache). On subsequent
visits I will just display a normal <script type="text/javascript">.. line.
However, this is jquery code and since jquery will not yet have been loaded
it will not work, can anyone translate this to "traditional" code or know an
alternative solution?
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/