Question:

If I link in two JavaScript files, both with $(document).ready functions, what happens? Does one overwrite the other? Or do both $(document).ready get called?

For example,

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>

<script type="text/javascript" src="https://.../jquery1.js"></script>

<script type="text/javascript" src="https://.../jquery2.js"></script>

jquery1.js :

$(document).ready(function(){
    $("#page-title").html("Document-ready was called!");
});

jquery2.js:

$(document).ready(function(){
    $("#page-subtitle").html("Document-ready was called!");
});

I’m sure it is best practice to simply combine both calls into a single $(document).ready but it’s not quite possible in my situation.

6 Answers
6

Leave a Reply

Your email address will not be published. Required fields are marked *