HTML and JavaScript: Safari and Loading Files

Today I experienced an odd issue with Safari. It appears as though the HTML attribute defer=”defer” is not translated by Safari. Below are two examples of code. The former was what worked in every major browser except Safari. The latter works in all browsers that I have tested.

<script type=”text/javascript” defer=”defer” src=”/js/file2.js”></script>
<script type=”text/javascript” defer=”defer” src=”/js/file3.js”></script>
<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js”></script>
<script type=”text/javascript” defer=”defer” src=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js”></script>
<script type=”text/javascript” defer=”defer” src=”/js/file1.js”></script>

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js”></script>
<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js”></script>
<script type=”text/javascript” defer=”defer” src=”/js/file1.js”></script>
<script type=”text/javascript” defer=”defer” src=”/js/file2.js”></script>
<script type=”text/javascript” defer=”defer” src=”/js/file3.js”></script>

The reason that the former was in that order was because of the way that Zend loads files via prependFile() and appendFile(). Using the proper combination of the two functions, I was able to get them into the desired order.

Nick

Leave a Reply