Which Method Will Make The Page Load Faster - Calling Code From A .js File 50 Times Slow Down Page Load?
May 12, 2011
I have a single webpage that contains information on all 50 U.S. states. There are 50 links at the top to jump down to the state you want, and at the bottom of the information for each state a Back to Top link.
I'm making the Back to Top link into something more complex, and it will require three or four lines of code.
So that I don't have to repeat the code 50 times, and create a burden when I need to edit it, I want to place it in a .js file and call it x. Then below the information for each state I'll simply have:
Does calling code from a .js file 50 times slow down the page load? Which method would load faster?
Is it faster/more beneficial to have two snippets of code be generated by php at 2 different urls and then have a load function for each url? Or have the two snippets on one page, surrounded by id's and then load them that way?
I have a page that contains 15 tabs. When each tab is pressed, it calls a function that uses .load() to load that tab. In my initial testing, all seems to go smoothly (loading in less than a second). However, once you click about 10 tabs, the pages start to load slower, and by click 13, it takes more than 30 seconds to load.If you refresh the page this process starts over and the outcome is the same (by click 12-13 it is unusable). Below is the code. FYI the reload_timer was an attempt to reload the page if the query was taking more than 10 seconds It didn't work. I left it in for feedback in case I don't find a suitable solution to the actual issue.
How can I make the script load after the page finishes loading? I tried creating a function at the end of the HTML and calling the function in the sidebar, but I think because the function was being called before the script was executed, it didn't work.
I have a table that is a production schedule of orders. Each order has 1 row with the main information and then 2 or 3 other rows with additional information. There could be 350+ rows. The pages loads fine by itself. I also have a function to expand/collapse individual rows when you click on them which works good. However, I wanted all the rows to be collapsed by default when the page loads. I added this code...
It works, but it is very slow. It could take 30+ seconds to run. Is there a faster way to use slideToggle on hundreds of rows at once? Or is there a better way to have them "closed" by default? ~bruno71
I'm having a problem where the serialize method isn't serializing form elements that are added to the DOM after the page load. Specifically, when the user clicks on a button some elements are displayed in a dialog that are generated from my server and returned via AJAX. I'm converting from Prototype and didn't run into this problem.
I have a list of names of flash files. On clicking anyone of them, flash file(.swf) whose path is know should play on the same webpage, on the right side of the list I know the code to play swf file. But here the file name has to be passed and what i need is to pass the file name at runtime depending on the link clicked.
I was reading up on how to load and parse an XML file into an html page and I found through w3 a great tutorial with sample code: [URL]. It appears to work fine on their website but when I try it from my desktop it doesn't work. So what I have is an html file with contents:
And then the xml file named "note.xml": <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> For the record I have tried this in chrome and ie.
What I want to do is to make an html page load a different background image every time it refreshes.I will have a list of background images and I want to be able to add in this list, without having to change anything else in the codes after I do this (I think this is made by making an array of images and by putting .length somewhere in the codes, but I don't know exactly how I should do this).I already know how to do an external file (.js) and link to it from my .html page.Now I want the code to put in the .js file, and the code to put in the <body> of my .html file.
I have an embedded video set in an iFrame (the page is called on.php). When someone clicks the stop video button, the iframe is re-directed to off.php, and the video is replaced with a play video button -- which when clicked takes them back to the video (on.php).
What I want to do is install a cookie that will permanently 'remember' which page the user has selected (on.php or off.php)... and then from that point forward will always load the appropriate page.
I've seen all sorts of tutorials about setting cookies and stuff, but nothing that would clue me in on how to accomplish what I'm trying to do specifically.
I have a text file that contains a whole bunch of data points neatly formatted (it's basically a CSV file). I need to create a quick JS function that would load the CSV file (from a URL) and display it with in a page. No parsing is needed! I just need to suck down the file and insert/display it within two div tags.