Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: HTML5  (Read 24360 times)

0 Members and 1 Guest are viewing this topic.

Veltas



    Intermediate

    Thanked: 7
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Linux variant
Re: HTML5
« Reply #15 on: January 09, 2012, 12:29:25 PM »
Also, with most websites using some form of server-side technology, web developers have no choice but know how to code.

There must be other facilities that don't require this... like PHPBB or whatever it is that people use for forums.

No, not necessarily. Just the storage thing, I think, uses Javascript.

I noticed a lot of scripting in CSS 3 too, is that not JavaScript or EcmaScript?

kpac

  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: HTML5
« Reply #16 on: January 09, 2012, 12:46:47 PM »
I think some terminology needs to be cleared up.

Server-side is PHP, ASP, ASP.NET, JSP, ColdFusion etc. This forum (SimpleMachines Forum) uses server-side technology - PHP - the same as phpBB or InvisionBoard or vBulletin. Anywhere a website communicates with the server - to send or retrieve data from a database for example is server-side. HTML or Javascript can't connect to a database alone.

Quote
I noticed a lot of scripting in CSS 3 too, is that not JavaScript or EcmaScript?
CSS 3 Javascript? Nope! CSS 3 is the same as CSS 2 with added effects.

Veltas



    Intermediate

    Thanked: 7
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Linux variant
Re: HTML5
« Reply #17 on: January 09, 2012, 01:31:32 PM »
CSS 3 Javascript? Nope! CSS 3 is the same as CSS 2 with added effects.

Yeah thanks I know, but what about the scripts in between the CSS?

kpac

  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: HTML5
« Reply #18 on: January 09, 2012, 03:08:02 PM »
I'm not sure what about scripts between the CSS...

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: HTML5
« Reply #19 on: January 09, 2012, 11:16:45 PM »
Quote
This is only a recent development
That's irrelevant. It's here now.
Quote
(half the reason Chrome caught developer's eyes so early on was its amazing out-of-this-world JavaScript performance)
If you ask me, Chrome's javascript interpreter, or at least it's implementation of certain behaviours, is broken.

Let's say I want to pop off an analytics pixel at unload time. We need a little delay to ensure the image request gets sent, so we shove in this little gem:
Code: [Select]
var s = e = new Date();

while (e.getTime() - s.getTime() < 500)
{
   e = new Date();
}


There! Works in every browser! Except Chrome- "Error: Too much time spent in unload handler"

OK, no problem. We'll just change it to this.

Code: [Select]
var s = e = new Date();

while (e.getTime() - s.getTime() < 1)
{
   e = new Date();
}

whew, glad that's out of th "Error: Too much time spent in unload handler."

So... one millisecond is too long? Is that what the error means? Why is chrome the only one that has this limitation? Guess though! Turns out that this error is a lie- it had nothing to do with the amount of time spent in the handler. It should really read, "Chrome detected you're trying to delay unload to ensure a pixel request goes through. Even though the only way to accomplish this is by delaying unload, we're going to be total dicks about it and pre-empt your attempt".

I mean, I can understand preventing too long of a delay, but basically providing a handler and refusing to do anything useful in it? What is that supposed to do?

You might think "well it's for security rite" Which I might agree with. The purpose if this code, by the way, is to try to keep track of what link was clicked to leave a page. I ended up working around it by creating my own Mini URL shortener service and having those links in the DB, so the page that redirects to it can record the link hit. Then I removed it because it was a pain in the *censored*, so now my DB has empty fields where the counts should be.  One might argue that "anything that tracks the user is inherently bad even if the purpose is to increase site usability"... Of course that sort of falls apart, since you can get the proper behaviour by just using this:

Code: [Select]
var s = e = new Date();

for( var i = 0; e.getTime() - s.getTime() < 500; i++)
{
   e = new Date();
}

So, why doesn't the original code work? It's some weird bit of hueristic done by chrome to prevent... well, I'm not sure.  It's quite targeted. you can use a while() loop, it doesn't trigger the error. Nor does calling getTime() on it's own. But if you call getTime in the condition or body of a while loop, poof- "too much time spent in unload handler".

it's really quite targeted. A while() loop alone doesn't trigger the behavior, nor does calling getTime() alone. But if you call getTime() in the condition or body of a while() loop, bam. I don't remember reading about this error being thrown in those specific conditions in the ECMA specification. The best I can tell is it was designed to prevent infinite loops in the BeforeUnload handler. I can totally understand preventing infinite loops in BeforeUnload handlers, because- duh. Thing is if the above behaviour is designed to do that, they missed a bunch of other ways to lock up their own browser:

Code: [Select]
var img = document.createElement('IMG');
img.src = 'http://url_i_want_to_load.png';
img.loaded = false;
img.onload = new Function('e', 'this.loaded = true');

while( !img.loaded )
{
  CodeToTrickChromeIntoThinkingThisCodeDoesSomethingUseful();
}
In that segment (mostly psuedocode) the while condition is never going to occur, because the image's onload handler cannot be trigger while in the middle of another handler. So, one might expect the browser to do toe usual "chug along for 30 or so seconds, complain about "this page stopped responding" and prompt to close it,right?

Nope. the tab's process pegs the CPU at 100% (or rather high, regardless) until the user forces the tab closed. It's an interesting day at the office when you accidentally learn how to write malicious javascript. Too bad it only works (or worked, they may have fixed this since I discovered it) in Chrome. Also too bad we have to write workaround code- only for chrome, mind you- to "fix" their special "prevent infinite loops" behaviour nonsense which doesn't even work.

Anyway- so when I first discovered this- as noted, the problem only cropped up in Chrome. IE? worked fine. IE6? Worked fine. Firefox? worked fine. Opera? don't know. didn't try it. etc. Only Chrome was a problem.

And people give IE a bad rap for making people write workaround code...

One of the major problems is that how browser makers and the W3C hold their hands up to their ears and yell "NAH NAH NAH NAH!!!" whenever the need for web analytics comes up. There really should be support for something this simple in the spec. Analytics aren't inherently evil, and if it's in the spec, one can control exactly what kind of information is kept track of, and what can be done (like not showing alerts and so forth). It's not like a server side page can't already track all sorts of stuff like refering URLs and IP addresses and whatnot. Seeing how people are leaving the page is hardly a bad thing.


Than again, all the browsers have their issues. I rather like this bug from 2001..


I'm not sure what about scripts between the CSS...

I have to echo your confusion...
I was trying to dereference Null Pointers before it was cool.

Veltas



    Intermediate

    Thanked: 7
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Linux variant
Re: HTML5
« Reply #20 on: January 10, 2012, 03:33:54 AM »
That's irrelevant. It's here now.

Doesn't matter, that wasn't my point.  My point in that line was that JavaScript requires more attention from the computer than Flash.

If you ask me, Chrome's javascript interpreter, or at least it's implementation of certain behaviours, is broken.

Maybe, but when they were first developing Chrome it ran JavaScript the fastest by far.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: HTML5
« Reply #21 on: January 10, 2012, 04:43:50 AM »
Doesn't matter, that wasn't my point.  My point in that line was that JavaScript requires more attention from the computer than Flash.
"More attention" is hardly something you can really quantify. If you mean it takes more processing power to run JavaScript over Flash; well, that's not accurate either, since, As I said, there are now JIT Compilers for Javascript; and, more importantly, ActionScript is still only compiled to bytecode (again, a more or less undocumented bytecode run by a single VM implementation that is entirely proprietary). As I said before, the primary reason for most browser "security issues" can usually be blamed on Flash.

I'd take a more security auditable and less black-box implementation using HTML5 over Flash any day.

Quote
Maybe, but when they were first developing Chrome it ran JavaScript the fastest by far.
It doesn't matter how fast your code runs if it doesn't work.
I was trying to dereference Null Pointers before it was cool.

Veltas



    Intermediate

    Thanked: 7
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Linux variant
Re: HTML5
« Reply #22 on: January 10, 2012, 05:07:14 AM »
I'd take a more security auditable and less black-box implementation using HTML5 over Flash any day.

If there was a W3C binary alternative it wouldn't technically be black-box, would it?

It doesn't matter how fast your code runs if it doesn't work.

Well obviously it worked enough... it may not even have been as bad as IE was at the time with JavaScript.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: HTML5
« Reply #23 on: January 10, 2012, 05:24:06 AM »
If there was a W3C binary alternative it wouldn't technically be black-box, would it?

um... why do you think that binary formats are better? They aren't. The speed gains from a Binary format is all in the parsing, and the fact is that in order to combat things like buffer overflow issues and malformed input, the reading code would need all sorts of sanity checks to make sure somebody isn't trying to screw with them. The burden of processing is on translating the Script or "binary" code into the internal data structures for execution, not in the actual load-time.

Quote
Well obviously it worked enough...
It was broken. see above broken implementation of an attempted "security feature" that required workaround code to deal with.

Quote
it may not even have been as bad as IE was at the time with JavaScript.
I've never had issues with Microsoft's Javascript implementation. I have with Chromes.
I was trying to dereference Null Pointers before it was cool.

Veltas



    Intermediate

    Thanked: 7
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Linux variant
Re: HTML5
« Reply #24 on: January 10, 2012, 05:35:23 AM »
I've never had issues with Microsoft's Javascript implementation. I have with Chromes.

Maybe I'm remembering wrongly.

Raptor

  • Guest
Re: HTML5
« Reply #25 on: January 10, 2012, 12:05:42 PM »
I wouldn't want to suffer from chromes.

Linux711

    Topic Starter


    Mentor

    Thanked: 59
    • Yes
    • Programming Blog
  • Certifications: List
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: HTML5
« Reply #26 on: January 10, 2012, 10:06:25 PM »
Quote
compiled to machine code on-the-fly

The difference in speed would result from this. Even if javascript is compiled, it's compiled on-the-fly where as flash is already precompiled to byte code resulting in faster execution.

Anyway, the main point of the post was comparing HTML5 to flash and even if HTML5 has its pluses, it will never compare to flash performance-wise.
YouTube

"Genius is persistence, not brain power." - Me

"Insomnia is just a byproduct of, "It can't be done"" - LaVolpe

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: HTML5
« Reply #27 on: January 11, 2012, 12:25:52 AM »
The difference in speed would result from this. Even if javascript is compiled, it's compiled on-the-fly where as flash is already precompiled to byte code resulting in faster execution.
No. the main branches of javascript on a page will be compiled quicker than the flash plugin can even load.

Quote
Anyway, the main point of the post was comparing HTML5 to flash and even if HTML5 has its pluses, it will never compare to flash performance-wise.

What do you base this on?

These tests indicate quite a different picture.
I was trying to dereference Null Pointers before it was cool.

Veltas



    Intermediate

    Thanked: 7
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Linux variant
Re: HTML5
« Reply #28 on: January 14, 2012, 08:21:56 PM »
Surely a lot of animation is done without much ActionScript use?  I don't think anyone's trying to say ActionScript runs faster than JavaScript.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: HTML5
« Reply #29 on: January 15, 2012, 05:32:17 AM »
Surely a lot of animation is done without much ActionScript use?  I don't think anyone's trying to say ActionScript runs faster than JavaScript.

I was trying to dereference Null Pointers before it was cool.