stargeek
PHP news website logo.
home    PHP scripts    articles    seo tools    links    search    contact    shop    realtors


How to detect long page loading times with Javascript







How to detect long page loading times
with Javascript

How to detect long page loading times
with Javascript
12/02/2002 01:17 PM




This is a GrokNews Entry: (what is grok?)





Similar Items

How to detect long page loading times with Javascript

Grok Headline matches for How to detect long page loading times with Javascript

Increase Safari's page loading speed


Increase Safari's page loading speed 05/19/2004 10:30 AM
Dave Hyatt made a post on his blog that describes a timer that Safari uses before it starts displaying any content. Supposedly the algorithm will be changed with the next release of Safari, but for now, you can still decrease...

Stop page loading in Safari by hitting
the Escape key


Stop page loading in Safari by hitting
the Escape key
11/11/2003 11:37 AM
Im not sure when it appeared, but you can stop a page from loading by simply hitting the Escape key in Safari v. 1.1 I have missed this for along time. So long, actually, that I have learned to live without it ;). [robg add...

Executing JavaScript on page load


Executing JavaScript on page load 05/26/2004 01:27 AM

Peter-Paul Koch recently wrote:

In my opinion, recent advances in JavaScript theory call for the removal of the event handlers that some Web developers-and all WYSIWYG editors-deploy in large masses in their XHTML files, where they don’t belong.

PPK is talking about inline event attributes such as the infamous onclick="" and onmouseover="" which have infested our HTML ever since Netscape introduced JavaScript back in version 2.0 of their browser. The alternative to these handlers is to add event handlers to elements after the document has loaded. PPK has detailed coverage of the various ways of doing this on his QuirksMode site.

In my work with unobtrusive JavaScript, I've found that by far the most common action I take is "registering" a script to be executed once the page has finished loading. There are a number of ways of doing this, which I described in my article E nhancing Structural Markup with JavaScript. Unfortunately, none of them are perfect if you wish to write truly reusable scripts.

For a script (such as my blockquote citations script discussed in the article) to be properly reusable, it needs to behave nicely in the presence of other scripts. This means that assigning a callback function directly to the window.onload handler is out of the question as doing so will over-ride previously assigned callbacks from other scripts. The correct way of adding a handler to an event without over-riding other handlers is to use modern event attachment method, which sadly differ between IE/Windows and other browsers. Scott Andrew's addEvent function handles the differences for you but comes with one major and rarely discussed drawback: it fails silently in IE5/Mac. If you care about the many Mac users still on OS9, you need to support that browser.

Anyway, I believe I've found a solution. Check this out:


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(function() {
  /* more code to run on page load */ 
});

The addLoadEvent function takes as an argument another function which should be executed once the page has loaded. Unlike assigning directly to window.onload, the function adds the event in such a way that any previously added onload functions will be executed first.

The way this works is relatively simple: if window.onload has not already been assigned a function, the function passed to addLoadEvent is simply assigned to window.onload. If window.onload has already been set, a brand new function is created which first calls the original onload handler, then calls the new handler afterwards.

addLoadEvent has one very important property: it will work even if something has previously been assigned to window.onload without using addLoadEvent itself. This makes it ideal for use in scripts that may be executing along side other scripts that have already been registered to execute once the page has loaded.

I've tested the above code successfully on IE 5, 5.5 and 6 for Windows; IE 5 and Safari for Mac; Opera 7.5 and FireFox on Mac (which should mean it works with those browsers on Windows as well). Opera 6 for Mac failed the test but has poor JavaScript support anyway and is hopefully becoming more and more rare now that Opera 7 has matured.

I've created a test page for the function. I'd be interested to here any bug reports from browsers I haven't covered.

I'm still considering ways in which this technique could be extended to work for generic events rather than just page loads. The challenge there would be to ensure that information about the event itself was passed to the event handlers in a consistent manner. For page load events this isn't an issue as the event object does not contain any valuable information.

Update: I've written the new technique up on my SitePoint blog and incorporated an explanation of closures and how they are used to preserve any previously assigned onload handlers.


How to Create a JavaScript Web Page
Screen Saver


How to Create a JavaScript Web Page
Screen Saver
06/08/2004 12:29 PM
This JavaScript tutorial shows you how to implement a screen saver on a web page. It activates after a timeout, hides the current content of the page, creates an attractive display and more. By Guyon Roche. 0608

At long last, Quark has posted a teaser
page about ...


At long last, Quark has posted a teaser
page about ...
03/13/2003 10:22 AM


At long last, Quark has posted a teaser page about XPress 6, the Carbonized, coming-sometime version of their page layout app. Sigh.

I used to be a graphic designer. I lived in Quark XPress. Thousands of hours, thousands of pages. I still remember the keyboard shortcut for "decrease tracking by 1/200th of an em," though I would rather not. It's not my bread and butter anymore, but I've been following the app's creep toward OS X, and like most have been boggled by the slow pace. In many cases this is the only thing binding design pros to OS 9. They want to migrate to OS X, but they can't.

As of this moment the page says almost nothing about the new version, only noting "enhanced undo functionality, full-resolution previews, and an intriguing way to manage complex projects." Strikingly uninformative -- and the screen shot promises little new other than Aqua trim on XPress's well-worn, spartan interface. Of course, we shouldn't judge print apps by web time. The task of publishing a magazine is substantially the same now as it was ten years ago, and most large publishing workgroups are slow to upgrade because of myriad software dependencies (I wonder how far they're gotten with updating QPS?). The important thing is that they get this thing out the frickin' door.

Though Quark is widely criticized in the industry for an unresponsive attitude toward customers, I really would like them to survive, because I believe that an Adobe monopoly -- which is what we are heading for -- would ultimately be bad for the industry. Discuss


A ten page New York Times


A ten page New York Times 09/26/2004 01:27 PM
loei van een artikel

nytimes.com/2004/09/26/magazine/26BLOGS.html?pagewanted=all& position=
track this site | 3 links


A Page-Turner at the Times


A Page-Turner at the Times 07/13/2004 08:43 AM
Is everything old new again?

A Long Look at Response to Brief (Los
Angeles Times)


A Long Look at Response to Brief (Los
Angeles Times)
04/12/2004 04:53 AM
Los Angeles Times - WASHINGTON — One day after the release of a top-secret report delivered to President Bush only five weeks before the Sept. 11 terrorist attacks, the spotlight shifted to a pair of new questions: How did the president respond? And what did the FBI do?

The Times has a front-page Sunday
article


The Times has a front-page Sunday
article
01/05/2004 04:59 AM
'05 budget

nytimes.com/2004/01/04/politics/04BUDG.html?hp
track this site | 3 links


NukeCops.com: Boost PHP Page Generation
Times with Zend


NukeCops.com: Boost PHP Page Generation
Times with Zend
06/22/2005 02:48 AM
On NukeCops.com, the site of the Official PHP-Nuke development team, there's this post with a bit of their experience with the Zend Optimizer.

A friend of mine recently installed Zend Optimizer 2.1.0 as we have here at Nuke Cops. Both sites are high traffic (50,000+ page hits daily) and pound the web server. Zend Optimizer 2.1.0 increases page generation times at least 50%.

Prior to having ZO installed our PHP generation times were anywhere from 2 to 4 seconds consistent. Once ZO was installed and set to default configuration out of the box, generation times dropped down to roughly 1.1 seconds. Default config had an optimization configuration set to "15". Server load times actually decreased as well from a 1.x-2.x down to a 0.5-1.x.

They even offer a simple, little-known tip to help get your pages out even faster: in the php.ini file, change the "optimization passes" setting from 15 to 1023. This will enable passes 9 and 10 and squeeze in that little extra bit to get the pages out that much faster (unfortunately, this also comes at a price - higher server load).

"Dazzling, full-color shots of people
long since dead, landscapes long since
paved, and an empire long since
overthrown."


"Dazzling, full-color shots of people
long since dead, landscapes long since
paved, and an empire long since
overthrown."
01/17/2004 11:07 PM

Mozilla Foundation Places Two-Page
Advocacy Ad in the New York Times


Mozilla Foundation Places Two-Page
Advocacy Ad in the New York Times
12/17/2004 06:41 PM

Schwarzenegger Has Long To-Do List to
Boost Business (Los Angeles Times)


Schwarzenegger Has Long To-Do List to
Boost Business (Los Angeles Times)
04/20/2004 04:43 AM
Los Angeles Times - After signing a massive workers' compensation insurance overhaul bill Monday, Gov. Arnold Schwarzenegger now is turning his persuasive powers to the next steps he deems necessary to bring clear skies to California's business climate.

Tough New Smog Rules Get Long Deadlines
(Los Angeles Times)


Tough New Smog Rules Get Long Deadlines
(Los Angeles Times)
04/16/2004 05:04 AM
Los Angeles Times - The Bush administration's new air quality standard will impose tougher requirements on the nation's smoggiest regions — Southern and Central California — but postpone the compliance deadline for so many years that local air officials worry that the regulations could be rendered ineffective.

Porn Actors' Struggles Began Long Before
HIV (Los Angeles Times)


Porn Actors' Struggles Began Long Before
HIV (Los Angeles Times)
05/05/2004 05:25 AM
Los Angeles Times - MONTREAL — He's a middle-aged black porn actor who had wanted to be a policeman. Known for his conscientiousness, he'd ask costars to refrain from smoking even as they were having unprotected group sex.

Firms Have a Long List of California
Turnoffs (Los Angeles Times)


Firms Have a Long List of California
Turnoffs (Los Angeles Times)
04/12/2004 07:28 AM
Los Angeles Times - Victor Monia is pleased that Gov. Arnold Schwarzenegger is wrapping his arms around the California workers' compensation problem. That doesn't mean the president of Visa Technologies, an electronics manufacturer in San Jose, is canceling his plans to move the 23-year-old business to Reno.

Finally .. after long long long time ..
Sonique 2 beta released


Finally .. after long long long time ..
Sonique 2 beta released
12/21/2003 03:42 PM

Long a Republican Bulwark, a Growing
Arizona Is in Play (Los Angeles Times)


Long a Republican Bulwark, a Growing
Arizona Is in Play (Los Angeles Times)
09/16/2004 05:13 AM
Los Angeles Times - PHOENIX — Louie Gomez lives in the new Arizona — the nation's second-fastest-growing state, where transplants from other regions are altering an entrenched conservative political culture.

In Aristide's Wake, a Land Long Divided
by Class, Color Explodes (Los Angeles
Times)


In Aristide's Wake, a Land Long Divided
by Class, Color Explodes (Los Angeles
Times)
03/06/2004 02:06 AM
Los Angeles Times - PETIONVILLE, Haiti — From the palm-shaded swimming pools and marble terraces of this wealthy suburb's hillside villas, the distant squalor of Port-au-Prince looks like a tranquil, opalescent coastal setting.

Professional JavaScript for Web
Developers: JavaScript in the Browser,
Pt. 1


Professional JavaScript for Web
Developers: JavaScript in the Browser,
Pt. 1
06/22/2005 02:51 AM
Web browsers have come a long way over the years and can now handle a variety of file formats, not just conventional HTML. Here, you'll learn how JavaScript fits into HTML, other languages, and some basic concepts of the Browser Object Model (BOM). By WROX Press. 0620

On Ellis Island, an Effort to Bring Its
Long-Hidden Side Into Public Light (Los
Angeles Times)


On Ellis Island, an Effort to Bring Its
Long-Hidden Side Into Public Light (Los
Angeles Times)
01/03/2005 06:23 AM
Los Angeles Times - ELLIS ISLAND, N.J. — On a chilly afternoon, wind and rain whip through the broken windows of a small, dark room where people with tuberculosis once stared out at the Statue of Liberty and wondered if they would ever begin a new life in America.

Quad-City Times Newspaper Online - the
Quad-Cities Home Page


Quad-City Times Newspaper Online - the
Quad-Cities Home Page
09/27/2004 09:19 AM
Gun cabinet locks no match for pen .. Keep bic pens away from your kids! .. More

qctimes.com/internal.php?story_id=1035941&l=1&t=Local+News&c=2, 1035941
track this site | 3 links


Log-Detect-1.414


Log-Detect-1.414 01/27/2004 06:21 PM

Lexington Herald-Leader | 07/04/2004 |
Front-page news, back-page coverage


Lexington Herald-Leader | 07/04/2004 |
Front-page news, back-page coverage
07/08/2004 02:18 AM
Noted in yesterday's Lexington [KY] Herald-Leader .. "We regret the omission." .. Read article .. Oops

kentucky.com/mld/kentucky/news/local/9077613.htm
track this site | 8 links


DNA 'Computer' Able to Detect Cancer


DNA 'Computer' Able to Detect Cancer 04/28/2004 02:44 PM
AP via ABCNEWS.com Apr 28 2004 6:22PM GMT

Detect and Repair mode


Detect and Repair mode 04/09/2004 03:54 PM

About once a month, Outlook becomes a pain in the ass for me to use for about 2 hours.

Inevitably, it'll hang on me while I'm doing something else, or some other process will hang while I'm using Outlook, and Outlook will refuse the shut down properly.

(I'm normally in the middle of about 15 things when this happens).

Detect and RepairfI'll shut down the XP box that I use, and let it sit for 20 minutes or so (I guess I'm hoping it'll get over whatever I did that made it mad at me).

After leaving it alone, I'll start it back up, and then I'll try to launch Outlook. It'll tell me that it wants to start in "Safe Mode" (and I'm like ... hmmm, does it normally run in 'un-safe' mode?). I'll let it try, and every-time, it'll faily to start up properly. I'll again, leave the machine alone for 20-30 minutes... hoping Outlook will figure out what's giving it problems, fix it, and then start up... about 90% of the time (or so it seems) it'll fail to start properly, and will just sit there telling me that it's "Not responding" (and I'm like "No Shit!")

So, I'll shut it down using the "End Process" command on the Windows Task Manager.

And then, I'll start up Outlook, and it'll tell me that something is horribly wrong, and that it needs to go into "Detect and Repair Mode". I'll click "ok" and then go away for another 20 minutes or so, while Outlook's installer tries to do it's thing.

About half of the time it works and Outlook continues to work (although it forgets some of my preferences).

The other half the time, I "rinse and repeat" this whole process.

This whole process happens about once a month, and it costs me around 2-3 hours each time it happens...

What a pain in the ass... total loss of productivity.

I don't think Apple Mail has ever 'ceased to function' on me, and I know that Mailsmith hasn't ever broken. Come to think of it, OS X has never crashed on me either...

Had to get that off my chest... Thanks for listening


UK chemists detect air fingerprints


UK chemists detect air fingerprints 06/09/2004 04:13 AM
I love the smell of VOC in the morning

DNA 'Computer' Able to Detect Cancer
(AP)


DNA 'Computer' Able to Detect Cancer
(AP)
04/28/2004 01:18 PM
AP - Researchers have developed a vanishingly tiny "computer" that could someday enable doctors to treat cancer and other diseases from inside the body.

System Can Detect Fraudulent Passports
(AP)


System Can Detect Fraudulent Passports
(AP)
04/09/2004 03:57 PM
AP - Australia, one of the United States' strongest allies, has added a new weapon to its arsenal — a toaster-sized document reader that tells in seconds whether a passport is a fraud and identifies travelers who might be included on terrorist watch lists.

System Can Detect Fraudulent Passports


System Can Detect Fraudulent Passports 04/10/2004 08:33 PM

detect library 0.9.83 (Default branch)


detect library 0.9.83 (Default branch) 03/28/2005 09:54 AM
The detect library can be used in any program that needs hardware detection features such as configuration tools, installation programs, etc. Its API is easy to learn and detection is easy to integrate too. It can be used to detect sound cards, CPUs, networking devices, webcams, joysticks, etc. It scans the IDE, PCI, ISA, USB, and SCSI busses to find hardware.

detect library 0.9.82 (Default branch)


detect library 0.9.82 (Default branch) 03/24/2005 01:28 PM
The detect library can be used in any program that needs hardware detection features such as configuration tools, installation programs, etc. Its API is easy to learn and detection is easy to integrate too. It can be used to detect sound cards, CPUs, networking devices, webcams, joysticks, etc. It scans the IDE, PCI, ISA, USB, and SCSI busses to find hardware.
Changes:
Detect is part of the XLine project now. New mouse detection code was added. Detection of video memory, monitors, and keyboards was added. Many bugfixes were made.

Astronomers Detect Saturnian Hot Spot


Astronomers Detect Saturnian Hot Spot 02/05/2005 09:19 PM

3D Holograms Detect Fake Signatures


3D Holograms Detect Fake Signatures 08/15/2004 08:56 PM

'Nanospring pill' could detect cancer
cells


'Nanospring pill' could detect cancer
cells
11/10/2003 11:16 PM
CNET Asia Nov 10 2003 10:35PM ET

NEC Develops Software To Detect
'Counterfeit' Batteries


NEC Develops Software To Detect
'Counterfeit' Batteries
07/07/2004 11:33 AM

nec_logo_blue.jpg imageI'm not sure I like this at all. In an effort to 'protect' consumers from the scourge of exploding batteries (and lower prices), NEC has developed software that detects "counterfeit battery products" in mobile phones and digital cameras. If the software simply detects that certain safety measures in place, but still allow for third-party batteries to be used, then that's probably fine (at least until the cheapo battery manufacturers start spoofing the safety hardware). However, if this software means that only NEC-branded batteries work in NEC products, that's going to be punch all of us right in the wallet, as NEC starts charging more per battery, likely under the auspice of "increasing prices due to more rigorous safety measures."

You know how I detect counterfeit batteries? If they smell like ham, and then I put them in my mouth and they are delicious, usually that means they aren't real. Otherwise, you know, if it's powering my phone, it's probably real enough for me.
Read - Software for Microcontrollers Verifies Authenticity of Mobile Phone and Digital Still Camera Batteries [NECEL via TheRawFeed]


Detect folder changes locally before
sync or mirror


Detect folder changes locally before
sync or mirror
03/19/2005 02:40 AM
Tools like rsync and lftp do a great job of mirroring directories between systems and only copying files that have been updated. On non-LAN networks, however, they still can be slow, since they have to query the remote system...

New German Mobile Phone to Detect Bad
Breath


New German Mobile Phone to Detect Bad
Breath
09/24/2004 10:20 PM

Direct and Related Links for 'New German Mobile Phone to Detect Bad Breath'

So you think that you have the hottest mobile phone out there, huh? Does it detect bad breath? You read that right folks, apparently a German telecommunications company is working a phone that does just that. This prompts me to ask the burning question of the hour, WHY?…

New German Mobile Phone to Detect Bad
Breath (Reuters)


New German Mobile Phone to Detect Bad
Breath (Reuters)
09/21/2004 12:46 PM
Reuters - A German telecommunications company said on Tuesday it is developing the first mobile phone that will alert users when their breath is bad or if they are giving off offensive smells.
Grok Description matches for How to detect long page loading times with Javascript
GrokA matches for How to detect long page loading times with Javascript

How to detect long page loading times with Javascript

The following phrases have been identified by the grok system as matching this entry:

















Also check out:


Grok

Ipod Porn on the
Rise

Brief Abstract of
Wikipedia's
Mesothelioma Cancer
page

Get first aid
instructions in your
cell phone

IE is crap
JSPWiki gains
podcasting support

Put a stop to
session hijacking

Back from the
holiday

Interview with
Andrei Zmievski

Msession enters beta
phase

Script Running
Machine

Web Database
Applications with
PHP and MySQL

PHP Platform
Discussion

NuSOAP: PHP SOAP
Library

PHP 4.2 has been
released

Programming PHP
Counting users
online with PHP

NuSphere PHPEd 3.0
released

QaDRAM Studio
Xdebug PHP Extension
Configuring PHP
engine

PHP and Templates
PHP Static Class
Variables

When Do Sessions
End?

Automatic PHP Class
Loading

PHP Security
XML and PHP
First Day, Again
Handling fatal and
parse errors in PHP

New keyboard
shortcuts

PHP at the
LinuxWorld Expo Oct.
29-31th in
Frankfurt, Germany

10th Release of the
PHP Manual CHM
Edition

PHP Search Bars
available for major
browsers

PHP site server
updates

New Monthly PHP
Magazine Launched

PHP Magazine -
International
Edition

Forum PHP 2002 in
Paris, France

PHP 4.3.0RC2
Released

PHP news feed
available

Spam Kill Ratios
Call for PHP Input
Postings Delayed for
a Bit Today

Size Matters When
Most of Your
Visitors are at 56k

Quick Color Class
Release Digest: KDE,
December 1, 2002

Bandwidth Saving
Technique #1

Bandwidth Saving
Technique #2

An Introduction To
Accessible Web
Design

Tips for Webmasters
cookiepuss (1
December 2002)

New Job
phpOpenTracker 1.0
Ships

First XML-RPC Post
I'm Back
costner (26 November
2002)

next (27 November
2002)

what is grok?