What happens when javascript fails?
First off, I'm quite new to javascript and jquery. But in the past couple months I've come a long ways.
My question is basically this:
I've got an onload event setup on my body, which uses the PerformanceTiming features to log certain data. My understanding is PerformanceTiming only works with browsers supporting HTML5
What happens is a clients browser does not support HTML5?
Will it stop executing javascript once it hits the unrecognized code? What about the execution of different javascript at a later point in the page life?
Basically I need to know if it's safe to use this code, when I know for sure certain machines won't be able to make sense of it.
My code is structured like this:
- <script type="text/javascript">
-
- var t = performance.timing;
- var kbytes;
- var networkLatency;
- var browserRenderTime;
- var totalTime;
- // Gets hit 1st
- $(document).ready(
- function () {
- var pagebytes = $('html').html().length;
- kbytes = pagebytes / 1024;
- $('#Div4').text('Page Size = ' + kbytes.toFixed(0) + 'Kb');
- }
- );
- // Gets hit 2nd
- var startTime = new Date().getTime();
- function onLoadEventHandler() {
- networkLatency = t.responseEnd - t.fetchStart;
- $('#Div1').text('Network latency = ' + networkLatency + 'ms');
- }
- // Gets hit 3rd
- $(window).load(function () {
- setTimeout(function () {
- browserRenderTime = t.loadEventEnd - t.responseEnd;
- totalTime = t.loadEventEnd - t.navigationStart;
- $('#Div2').text('The time taken for client machine to render page = ' + browserRenderTime + 'ms');
- $('#Div3').text('The whole process = ' + totalTime + 'ms');
- var data = kbytes.toFixed(0);
- data += "|" + $('#DivServerExecutionTime').text();
- data += "|" + networkLatency;
- data += "|" + browserRenderTime;
- data += "|" + totalTime;
- data += "|" + (screen.width + " x " + screen.height);
- data += "|" + window.location;
- $.ajax({
- type: 'POST',
- url: "/handlers/PageloadSpeeds.ashx",
- cache: false,
- data: data
- });
- }, 0);
- });
- </script>