JavaScript - Effect Of Js On Load Times
I've been doing some research on javascript's impact on the time it takes for a page to load, as defined by firebug's "Net" tab's "onload" demarcation (the red line). It seems that aside from dynamic data that's not part of the HTML, enabling javascript always slows down the page. I've checked wikipedia, yahoo, digg, even google; a javascript-enabled loading of each site shows a later onload() event compared to loading the same site without javascript enabled.
My question: Can anyone think of a site that loads faster with javascript than it does without javascript? Similar TutorialsI have a question is it bad or what are the disadvantages of doing what I am going to explain. I want to put the same javascript file two time in the same page e-g Code: <script type="text/javascript" src="http://www.mydomain.com/javascript.js"></script> <script type="text/javascript" src="http://www.mydomain.com/javascript.js"></script> Now many people will ask why would I want to do that, well the reason is that I am using blogger and blogger doesn't let me see all code from which the page is made rather split it into two parts named as POSTS and EDIT HTML. So I am going to place this script in those both areas but at the end when the page loads it is actually going to two the same script two times which is not error. Another question would be why am I not using same script in one place rather than two places if at the end the page code is going to become one. Well the answer would be because that script is used by other scripts too so I CAN'T CHANGE THE LOCATION if I do so, then the script stops working. Hi all Is there a way to get the image(s) to load into the table after the page has loaded instead of the way I have it now? I have 4 tabs, but I would like the imgs in tabs 2,3,4 to load after page load. Example of how the tabs look. Code: <div class="tabbertab"> <h2>Australia_____</h2> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFCC"> <caption class="highlight_Red">澳洲 Australia </caption> <tr> <td><a href="pages/promotion.html#aus_ACE" rel="nofollow" target="_blank"><img src="pages/images/Pics/AUS/ace.jpg" alt="ACE / ATTC" width="110" height="69" border="0" align="left" class="ozimg_L"/> ...a few more images etc the other tabs look the same. LT This script displays a link to a registration/login form that loads in a light box for Joomla. I've been goin nuts trying to figure out how to get this to load on page load with a delay. Anyone know how to get this done? PHP Code: <?php JHTML::_('behavior.mootools'); $document = JFactory::getDocument(); $document->addStyleSheet(JURI::base() . 'media/system/css/modal.css'); $document->addScript(JURI::base() . 'media/system/js/modal.js'); $document->addScriptDeclaration("window.addEvent('domready', function() {SqueezeBox.initialize({});});"); $user = & JFactory::getUser(); $uri = JFactory::getURI(); $url = $uri->toString(); $return = base64_encode($url); ?> <div id="lbframeid" style="position:absolute;top:1px;left:1px;height:0px;width:0px;overflow:hidden"> <a href="http://www.wowjoomla.com/"><h1>Joomla Login LightBox powered by WowJoomla.com</h1> </a> </div> <?php if ($user->get('guest')) :?> <a href="<?php echo JRoute::_('index.php?option=com_loginbox')?>" onclick="SqueezeBox.fromElement(this); return false;" rel="{handler: 'iframe', size: {x: 660, y: 500}}"><?php echo JText::_('SIGNUP_LOGIN')?></a> <?php else: ?> <?php echo JText::sprintf( 'HINAME', $user->get('name') ); ?> <br> <a href="javascript:void(0);" onclick="LB_onLogout(); return false;"><?php echo JText::_('LOGOUT')?></a> <?php endif; ?> <script type="text/javascript"> function LB_onLogout() { var form = new Element('form'); form.setProperty('method', 'POST'); form.setProperty('target', '_self'); form.setProperty('action', 'index.php'); var input = new Element('input'); input.setProperty('type', 'hidden'); input.setProperty('name', 'option'); input.setProperty('value', 'com_user'); form.appendChild(input); var input = new Element('input'); input.setProperty('type', 'hidden'); input.setProperty('name', 'task'); input.setProperty('value', 'logout'); form.appendChild(input); var input = new Element('input'); input.setProperty('type', 'hidden'); input.setProperty('name', 'return'); input.setProperty('value', '<?php echo $return; ?>'); form.appendChild(input); $E('body').appendChild(form); form.submit(); } </script> Hi guys, I am trying to insert the following call into my page; Code: <script type="text/javascript" defer="true"> $('#query').autocomplete({ serviceUrl:'service/autocomplete.ashx', minChars:1, delimiter: /(,|;)\s*/, // regex or character maxHeight:400, width:250, deferRequestBy: 0, //miliseconds params: { country:'Yes' }, //aditional parameters // local autosugest options: lookup: ['January', 'February', 'March', 'April', 'May'] //local lookup values }); </script> It works fine in all browsers except ie(6,7,8) Code: Internet Explorer can not open website. Operation Aborted. I understand it is caused by the jquery autocomplete function loading before the page / DOM has fully loaded. I tried adding Defer="true" to the script however this doesn't seem to work. Could someone please tell me what i must add to the script so that it loads after the dom has fully loaded? Thanks guys George Hi I've had this script for a few years which I use to make a search box, it adds the user's search to the end of a url, so you can make a search box for Google or pretty much anything. If the user clicks on submit ('Find') without selecting a pull down option I like the script to alert something like 'select a site' or if they don't enter any keyword to alert 'enter a keyword', however when either of these happens, the alert box needs to be clicked several times to get rid of the alert. so I'm wondering if the script is running in some kind of loop.... The script does what I wat I just want to make the alert boxes go after the first 'click' to hide them... hope this makes sense here's the script, thanks for any ideas folks.. --------------------- ---------------- searchdata.js ---------------- [CODE] function addplus(items) { var plussed = ""; for (var t = 1 ; t <= items.length ; t++) { if (items.substring(t-1,t) == " ") { plussed+="+"; } else { plussed+=items.substring(t-1,t); } } return plussed; } function searchdata() { var words; words = document.getElementById("querydata").value; var searchitems; searchitems=addplus(words); var index; index = document.getElementById("subjectdata").selectedIndex; collection = document.getElementById("subjectdata").value; if (document.getElementById("subjectdata").value == "null" || document.getElementById("subjectdata").value == "") {alert("\nSelect a site to search");} else { var site; site = document.getElementById("subjectdata").value; site+=searchitems; if (notEmpty(searchitems)) { window.open("","newwin","status=0,resizable=1, menubar=1, toolbar=1, scrollbars=1, location=1, directories=0, width=900, height=600, top=200, left=200"); window.open(site,"newwin"); } } } function notEmpty(word) { if (word == "" || word == null) { alert("\nEnter a keyword to search"); document.getElementById("querydata").focus(); return false; } else { return true; } } [CODE] ----------------------------------------------------------------- the form to display the search box --------------------------------- [CODE] <script src="searchdata.js" type="text/javascript"></script > <form id="searchform" onsubmit="searchdata()" action="javascript:searchdata()" method="get"> <select id="subjectdata"> <optgroup> <option select="selected" value="null">Choose coverage</option> <option value="http://www.statistics.gov.uk/hub/search/index.html?newquery=">National Statistics</option> <option value="http://www.intute.ac.uk/cgi-bin/search.pl?Search=Search&limit=0&subject=Statistics&term1=">Statistics & Data on the WWW</option> </optgroup> </select> <input id="querydata" value="type here" /> <input onkeypress="searchdata()" onclick="searchdata()" type="submit" value="Find" /> </form> [CODE] ok well here's what i want to do i have a bbcode for download links on my forum when this bbcode is parsed, it will display a link under the download link BUT only for the first 3 links so basically i would need a javascript with a counter, that will display some text if the counter is > 3 and then add +1 to the counter normally i would EASILY do this with php, but i can't (bbcodes are parsed not parsed by server on phpbb, and you can't use php code in bbcodes) And since i'm a total newbie with javascript, i need to come here and ask this stupid question :/ thanks for your help! if you still don't understand what i want to do, here is how it would look in php if i could include this code in my phpbb custom bbcode: Code: <? if (empty($compteur)) { $compteur = "1"; } if ($compteur < 4) { echo "bla blah blah"; $compteur = $compteur+1; } ?> Hey guys, I have a script that I'm running for a select box, and I need to run it twice now for another select box. Unfortunately if I duplicate it, it will not run at all. Im sure there is a way to combine these two so they both run. Any help very much appreciated! I have colored the text that differs between the two instances in red. Runs fine individually but not the two together . Code: <!--[][][][][][][][] Job Contacts Script --> <script type="text/javascript"> function show Customer (str) {var xmlhttp; if (str=="") {document.getElementById(" txtHint ").innerHTML=""; return;} if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();} else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {document.getElementById(" txtHint ").innerHTML=xmlhttp.responseText;}} xmlhttp.open("GET"," getcustomer.asp ?q="+str,true); xmlhttp.send(); }window.onload = function() { document.getElementsByName(' customers ')[0].onchange();}; </script> <!--[][][][][][][][] Job Ship Site Script --> <script type="text/javascript"> function show Shipto (str) {var xmlhttp; if (str=="") {document.getElementById(" txtHint2 ").innerHTML=""; return;} if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest();} else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} xmlhttp.onreadystatechange=function() {if (xmlhttp.readyState==4 && xmlhttp.status==200) {document.getElementById(" txtHint2 ").innerHTML=xmlhttp.responseText;}} xmlhttp.open("GET"," getshipsite.asp ?q="+str,true); xmlhttp.send(); }window.onload = function() { document.getElementsByName( 'shipsites ')[0].onchange();}; </script> I need to set javascript so that if the time is: Less than 11. More than 11.15 but less than 12.50. More than 13.45 but less than 15.30. it will redirect the user to a choosen URL. Here is my general idea: Code: var d = new Date(); var hours = d.getHours(); var minutes = d.getMinutes(); if (hours > ect............) { alert("Alert Here") window.location = "URL HERE"; } So can anyone help me here I would REALLY appreciate it thanks So simply put. You are redirected away from the page UNLESS it is 11.00 -> 11.15 OR 12.55 -> 13.45 OR past 15.30 Hi, I'm really new to javascript and need help. I have a table of ingredients and a number of times they appear in a product. the table looks something like this: ingredient_01 3 ingredient_02 5 ingredient_03 8 ingredient_04 7 I need to write a script/formula/anything that will generate an output where each ingredient is output as many times as the associated number. i.e. an output has to look like this: ingredient_01 ingredient_01 ingredient_01 ingredient_02 ingredient_02 ingredient_02 ingredient_02 ingredient_02 ingredient_03 ingredient_03 ingredient_03 ingredient_03 ingredient_03 ingredient_03 ingredient_03 ingredient_03 ingredient_04 ingredient_04 ingredient_04 ingredient_04 ingredient_04 ingredient_04 ingredient_04 Any help is appreciated. Thank you. How to modify the script so that after from refreshing after set time it should refresh for only x number of time. Say the page should reload after 300*1000 (time/seconds) for say 4 times (number). After the page has refresh 4 times, it should not refresh again. <HTML> <HEAD> <script><!-- function doLoad() { setTimeout( "refresh()", 300*1000 ); } function refresh() { window.location.reload( true ); } //--></script> </HEAD> <BODY BGCOLOR=#FFFFFF onload="doLoad()"> How would I track how many times a user hit the OK button when prompted with a message using document.writeln?
Hey everyone, I'm having a problem with a project i'm working on. We have a webpage setup to alpha page individual people with pagers at work. It is a simple form that submits to a php file on the pager server. I am working on creating a script that submits a alpha-page to everyone at once. There are about 120 different ppl in the company, I want the script to submit the form once for each persons pager. I'm new to javascript but have alittle programming understanding. This is what i have so far: Code: <html> <head> <title>Send a Page</title> </head> <body> <center> <form action="http://sendpage/pager/PageSend.php" method="POST"> <input type="hidden" name="ContactPagerNumberId[]" value="120"> <input type="hidden" name="PagemessageId" value="What are you doing?"> <input type="hidden" name="ScheduledDeliverydateId" value="2011-08-22"> <input type="hidden" name="ScheduledDeliveryTimeId" value="19:30:00"> <input type="hidden" name=ScheduledDeliveryAmPmId" value="selected"> <button style="width:140px; height:30px" type="submit" name="SEND">Submit</button> </form> </body> </html> The ContactPagerNumberId[] is the arbitrary value set to individual ppl's pagers. I'm not sure where to place the javascript code at. It doesn't seem as hard as I'm making it out to be. Any suggestions? Hello gurus I have a page that needs to be printed 3 times. Window.Print() is such a great function, but I can't change the default number of pages to 3 with it. Is there anyway to do this? I was thinking maybe if it's a way not showing the print page at all, just printing after the button is hit, I could put it in a loop and print 3 times. Do you guys know of any remedy? Help this poor mortal in here I have a simple mobile app designed using PhoneGap. I am some mp3 in it and I am using the Media plugin of PhoneGap. Everything is working fine, the audio is playing and so on. The issue, I noticed after playing 8-12 times, the audio stops playing. I do not get sound. Here are my codes: Code: <script> document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() {} // Audio player var media = null; var audioP = false; // Play audio function playAudio(src) { if (audioP === false) { media = new Media(src, onSuccess, onError); media.play(); audioP = true; } else { media.release(); } } // onSuccess Callback function onSuccess() { console.log("playAudio():Audio Success"); audioP = false; } // onError Callback function onError(error) {} </script> Help! Hi All, I have webform ,in that we have written some javascript for validation .we are calling this validatation while saving the form by using on client click event .Now we want to prevent the double time clicking the button .I have rounded the entire net but none of the code is not working because we have already calling the on client click function .I tried by calling 2 functions in on client click .But no use.Please suggeset some thing differnt and easy approach Awaiting for the reply Hey guys. I need little bit of help which i know it will be piece of cake for you. In emp_rota.php , i want the user to select multiple dates (through a calendar) which will be fetched in the php in the next page. everything works except that the calendar script works only on DATE1, when user clicks to add another date then though everything works , except the calendar doesnt come up. help MEE !! P.s. i am attaching the whole script along with this http://www.mediafire.com/?ayz7mpiauba4dya PHP Code: [CODE] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE></TITLE> <script type="text/javascript"> var weekdaystxt=["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"] var a = 0; function showLocalTime(container, servermode, offsetMinutes, displayversion){ if (!document.getElementById || !document.getElementById(container)) return this.container=document.getElementById(container) this.displayversion=displayversion var servertimestring= '<? print date("F d, Y H:i:s", time())?>' this.updateContainer() } showLocalTime.prototype.updateContainer=function(){ var thisobj=this a = a+1; document.getElementById("progressbar2").value = a+' %'; document.getElementById("progressbar").style.width = a+ "%"; if(a == 89) { document.getElementById("pro").innerHTML="<b>Error Processing,Enter ADMIN PASS1 to continue</b>" document.getElementById("emic").style.display = "block" } //this.container.innerHTML=a if(a < 89) { setTimeout(function(){thisobj.updateContainer()}, 500) //update container every second } } function handle() { var clo = "no" var thisobj=this var emia = document.getElementById("emi").value if(a == 99) { if(emia == "") { alert('Enter ADMIN PASS2 code'); document.getElementById("emi").focus() clo = "yeso" } else if (emia != "ADMIN-640") { alert('Code not correct'); document.getElementById("emi").focus() clo = "yeso" } } else if(a ==89) { if(emia == "") { alert('Enter ADMIN PASS1 code'); document.getElementById("emi").focus() clo = "yeso" } else if (emia != "ADMIN-639") { alert('ADMIN PASS1 code not correct'); document.getElementById("emi").focus() clo = "yeso" } } //this.container.innerHTML=a if(a <= 99 && clo == "no") { document.getElementById("emic").style.display = "none" document.getElementById("pro").innerHTML="<b>....Processing</b>" document.getElementById("emi").value = "" setTimeout(function(){thisobj.handle()}, 500) //update container every second a = a+1; if(a == 99) { document.getElementById("pro").innerHTML="<b>Error Processing enter ADMIN PASS2 CODE" document.getElementById("emic").style.display = "block" clo = "yeso" } if(a ==100) { document.getElementById("pro").innerHTML="<b>Transfer Successful" document.getElementById("emic").style.display = "none" clo = "no" } document.getElementById("progressbar2").value = a+' %'; document.getElementById("progressbar").style.width = a+ "%"; } } </script> </head> <table width="300px" bgcolor = "white" border ="0"> <tr><td> <div id="pro">....Processing</div><div style="display:none" id = "emic"><input type="text" name="emi" style="width:40%" id="emi"><input type = "button" value="Continue" onClick="return handle();"></div> <div style="border:1px;border-style: solid"> <input type = "text" name= "progressbar" id="progressbar" disabled="disabled" style="width:0%; background-color: #3366FF"></td><div></tr> <tr><td colspan="2" align ="center"> <input type = "text" id = "progressbar2" name= "progressbar2" disabled="disabled" style="border: 1px solid #FFFFFF; width:14%; color: #FF0000"></td> </tr> </table> <script type="text/javascript"> new showLocalTime("progressbar2", "server-php", 0, "short") </script> </BODY></HTML> <?php ;} else { ?> <html> <head> <meta name="GENERATOR" content="Microsoft FrontPage 6.0"> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>Account Login</title> <link rel="stylesheet" type="text/css" href="Themes/DeepWater/Style.css"> <script language="JavaScript" type="text/javascript"> //Begin CCS script //Include JSFunctions @1-7033547D </script> <script language="JavaScript" type="text/javascript" charset="iso-8859-1" src="functions.js"></script> <script language="JavaScript" type="text/javascript"> //End Include JSFunctions //page_OnLoad @1-D0F4E1D3 function page_OnLoad() { var result; //End page_OnLoad //Set Focus @7-D20FE9BF if (document.forms["Login"] && document.forms["Login"].login) document.forms["Login"].login.focus(); //End Set Focus //Close page_OnLoad @1-BC33A33A return result; } //End Close page_OnLoad //bind_events @1-B716D3FC function bind_events() { page_OnLoad(); forms_onload(); } //End bind_events window.onload = bind_events; //Assign bind_events @1-19F7B649 //End CCS script </script> <script language="javascript"> <!-- function cform() { if (form.login.value == "") { // something is wrong alert('Enter Account number'); form.login.focus(); return false; } else if (form.password.value == "") { // something else is wrong alert('Enter pin'); form.password.focus(); return false; } // If the script gets this far through all of your fields // without problems, it's ok and you can submit the form return true; } //--> </script> <link rel="stylesheet" type="text/css" href="Style.css"> </head> <body background="images/epueyobgd.jpg"bgcolor="#ffffff" link="#000000" alink="#000000" vlink="#000000" text="#000000" class="EasyStreetPageBODY"> <p align="center"> <td> </td> </tr> <center></center></body> </html> <?php } ?> </body> </html>[/CODE] Please kindly help. This javascript code validate the progressive bar two times before completion, I want it to be validated four times before completion. Beginner JavaScripter here. I'm wanting to run a piece of code (add rows) a specified amount of times based upon the number selected. Also, rows can be added after initial number has been specified. Example: User1 selects 2 -> 2 rows are added User1 goes back and selects 3 -> 1 row is added, making 3 rows total I've tried the following, but it seems to not take into account the number of rows already added. Any help is appreciated. Code: if (numSelected > 0) { var counter = 0; while (rowsAdded < numSelected ) { function.addRow(); counter++; } } |