Current time: 09-23-2019, 11:20 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to defer parsing javascript
11-22-2011, 10:25 AM (This post was last modified: 11-22-2011 10:30 AM by Joel.)
Post: #8
RE: how to defer parsing javascript
First thanks for your time (see you answered 2 of my questions!)

I tested with Google's suggestion, and the JS didn't work, maybe I did it wrong, that's why I asked for more specific help using our code as an example.
for example here is some code we use:
Code:
<script type='text/javascript' src='/images/css/jquery.autocomplete.js'></script>

<script type="text/javascript">
(function($) {
$().ready(function() {

    function formatItem(row) {
        return row[0] + " (" + row[1] + ")";
    }
    function formatResult(row) {
        return row[0].replace(/(<.+?>)/gi, '');
    }
    $('#suggest4').autocomplete('/index.php?action=autocomplete', {
        width: 300,
        matchContains: true,
        formatItem: formatItem
        }).result(function(event, row) {
               location.href = "/" + row[2] ;
        });

    $("#clear").click(function() {
        $(":input").unautocomplete();
    });
});
})(jQuery);
</script>

which part should go into here:
Code:
<script type="text/javascript">

// Add a script element as a child of the body
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "deferredfunctions.js";
document.body.appendChild(element);
}

// Check for browser support of event handling capability
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;

</script>

I didn't test with your code, because as per w3schools
Quote:The defer attribute is only supported by Internet Explorer.
http://www.w3schools.com/tags/att_script_defer.asp

Thanks so much for your time!
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
how to defer parsing javascript - Joel - 11-15-2011, 04:47 AM
RE: how to defer parsing javascript - Joel - 11-15-2011, 06:44 AM
RE: how to defer parsing javascript - Joel - 11-15-2011, 07:35 AM
RE: how to defer parsing javascript - Joel - 11-22-2011 10:25 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)