Open Side Menu Go to the Top

06-07-2011 , 04:01 AM
I have had no problems with compatability with HTML5 as long as you don't apply styles to HTML5 elements (IE don't use <nav> as your wrapper with styles, put an inner div inside it)
HTML5/CSS3/advancedJavascript learning and programming logs Quote
HTML5/CSS3/advancedJavascript learning and programming logs
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
HTML5/CSS3/advancedJavascript learning and programming logs
06-07-2011 , 04:34 AM
As long as you have the reset, you don't need to add all the other divs. Why bother with doing that?
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-07-2011 , 04:37 AM
Good question, I've never really used resets before, it's just the way I've done it. I'll be looking at it for future work though.

Does the reset allow you to style nav tags, section tags etc then in IE6/7/8?
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-07-2011 , 06:16 AM
yes, at least on my computer.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-07-2011 , 06:18 AM
Also if the user has JS disabled? (I can't find the link to the reset page your using sorry!)
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-07-2011 , 07:10 AM
http://meyerweb.com/eric/tools/css/reset/

http://code.google.com/p/html5shiv/

not having js enabled shouldn't be a problem as long as you code it normally.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-07-2011 , 01:24 PM
Unfortunately you do need JS enabled for the shiv to work. The shiv controls whether or not IE sees the new html5 elements.

Meyer's reset doesn't create the element, it just sets its properties to a standardized default value.

The shiv uses JS to create the element.

By the way, it's "nginx" (the event based web server), and it has nothing to do with nodejs. You can serve PHP with nginx if you wanted to, but you would need to create your own asynchronous code to take advantage of nginx's benefits.

If you wanted to use PHP with nginx and you were using mysql you would have to write your own db adapter or find an asynch version of it, etc..

That is why nodejs is getting so much attention. It's built off JS which naturally has all asynch libraries since previously it was being used on the browser (the browser is 1 big event loop).
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-07-2011 , 02:55 PM
Quote:
Originally Posted by Shoe Lace
That is why nodejs is getting so much attention. It's built off JS which naturally has all asynch libraries since previously it was being used on the browser (the browser is 1 big event loop).
I am not sure that I would agree that JS is naturally async. When it runs in the browser it only has 1 thread and so is effectively blocking (with the exception of web workers and ajax requests). However, since many of the nodejs libraries are being built from scratch, there is an opportunity to make them all async, and that opportunity has been taken. Try this with any other language, and you wont get far until you find some blocking code you cant get round....
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-07-2011 , 03:14 PM
NodeJS is running on 1 thread too. It's an event loop. I'm on my way out so I can't give you a detailed response, I'll write more about this later.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-07-2011 , 03:19 PM
Quote:
Originally Posted by Shoe Lace
NodeJS is running on 1 thread too. It's an event loop. I'm on my way out so I can't give you a detailed response, I'll write more about this later.
Yes node itself runs in a single event, this is true, but all the libraries written for nodejs are async.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-07-2011 , 10:39 PM
No, it runs in a single thread. There could be many events.

Having 1 thread doesn't mean it's blocking (which you said in the previous reply). Think of what happens when you run this jquery code in the browser:

Code:
$('#someId').click(function() {
  alert('Cool story.');
});
This is an event right? Behind the scenes jquery is publishing the event, registering the event handler, and listening for the event.

It wraps all of that functionality into something very simple. Supply the event, and supply a callback. The anonymous function is the callback.

The thread isn't blocked in a way that the browser can't do anything while the id isn't clicked. It's doing many other things, and when that event occurs it triggers the callback.

Now, let's look at the node hello world:

Code:
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
A very similar thing is happening here. It's listening on a port/IP for an http request. Every time someone hits it, it's running the anonymous function.

Apache would keep spawning new threads for each connection because it is synchronous/blocking. This is why it sucks monkey balls for concurrency; you eventually have so many threads that it cripples your server.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-08-2011 , 02:37 AM
How does the event listening work in a single thread?
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-08-2011 , 03:18 AM
I mis-wrote, so I'll clarify: "if you code properly, you will have a site that degrades gracefully." I think it is funny that someone who really goes through the trouble of turning of javaScript in IE (and this has to be super rare) would expect that everything will work properly.

So, if you really want to go through the trouble of making sure your site works in all browsers, even with javaScript off:

Code:
<!DOCTYPE html>
<html lang="en">
<head>

<!--[if lt IE 9]>   <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->

<link rel="stylesheet" href="altReset.css" />

<style type="text/css">

header, article, footer, div{
width: 5em;
background-color: green;
border: 1px outset grey;
margin: 1em;
float: left;
}

</style>

</head> 
<body>

<!--[if lt IE 9]>
<div>
<![endif]-->
<header>
<hgroup>
</h1>HELLO</h1>
<p>world</p>
</hgroup>
</header>
<!--[if lt IE 9]>
</div>
<![endif]-->

<!--[if lt IE 9]>
<div>
<![endif]-->
<article>
<hgroup>
</h1>HELLO</h1>
<p>world</p>
</hgroup>
</article>
<!--[if lt IE 9]>
</div>
<![endif]-->

<!--[if lt IE 9]>
<div>
<![endif]-->
<article>
<hgroup>
</h1>HELLO</h1>
<p>world</p>
</hgroup>
</article>
<!--[if lt IE 9]>
</div>
<![endif]-->

<!--[if lt IE 9]>
<div>
<![endif]-->
<article>
<hgroup>
</h1>HELLO</h1>
<p>world</p>
</hgroup>
</article>
<!--[if lt IE 9]>
</div>
<![endif]-->

<!--[if lt IE 9]>
<div>
<![endif]-->
<footer>
<hgroup>
</h1>HELLO</h1>
<p>world</p>
</hgroup>
</footer>
<!--[if lt IE 9]>
</div>
<![endif]-->


</body>
</html>
But there is an issue, and excuse me if the following sound ignorant because I don't know crap about back-end programming:

See all those <hgroups>? Those are needed if you want to use all <h1> and you don't want to break the DOM while doing so. Now, if your program is dependent on manipulating the DOM, then you are really up a crick.

This does not mean that learning HTML5 is a total waste. As I pointed out earlier, ie8 added support to <canvas> and they may add support for the other elements soon as well. If not, there are still many things that are offered with HTML5: local storage, geolocation, and of course new form attributes. The great thing about form attributes is that they degrade perfectly into ie7/8/9, but they are helpful to people with iPhones and screen readers.

diveIntoHTML5 goes into massive detail about all this stuff, and explains it better than I can.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-08-2011 , 03:27 AM
Quote:
Originally Posted by Shoe Lace
No, it runs in a single thread. There could be many events.

Having 1 thread doesn't mean it's blocking (which you said in the previous reply). Think of what happens when you run this jquery code in the browser:

Code:
$('#someId').click(function() {
  alert('Cool story.');
});
This is an event right? Behind the scenes jquery is publishing the event, registering the event handler, and listening for the event.

It wraps all of that functionality into something very simple. Supply the event, and supply a callback. The anonymous function is the callback.

The thread isn't blocked in a way that the browser can't do anything while the id isn't clicked. It's doing many other things, and when that event occurs it triggers the callback.

Now, let's look at the node hello world:

Code:
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
A very similar thing is happening here. It's listening on a port/IP for an http request. Every time someone hits it, it's running the anonymous function.

Apache would keep spawning new threads for each connection because it is synchronous/blocking. This is why it sucks monkey balls for concurrency; you eventually have so many threads that it cripples your server.
Thanks for the summary, looks like I was slightly off the mark in my post. Ye, the performance differences between node and apache are redic.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-08-2011 , 04:05 AM
That's why I'm wary of using JS to fix compatibility issues, it doesn't degrade gracefully. I'd rather just have an inner div inside the HTML5 tags, it's simple and it works fine.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-08-2011 , 05:58 AM
I guess the [if lt IE 9] solution is fine if you don't want to use javaScript. At least you know for sure why you have the extra div, and you can easily add that extra div to the style with a comma, but having div inside a tag just so you can style the tag is plain weird to me. It has to be confusing as all get-out to read that. I wouldn't even bother using the new tags in this case.

But what happens when you have a layout like:

Code:
<nav>
<div>
</div>
</nav>
You have two block elements and one is going to be smaller than the other, and that can't possibly create a similar layout across all browsers. Just look at how ff4 and Chrome render the elements, then float a div with matching width/height next to them and see how the layouts differ. It was for this reason I started using the CSS reset in the first place. The reset had nothing to do with IE, though it is needed there as well.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-08-2011 , 03:00 PM
Quote:
Originally Posted by gaming_mouse
How does the event listening work in a single thread?
The most popular method is callbacks. It's sort of like cooking in real life.

If you cook pasta but you also want to toast some garlic bread you won't turn the stove on to boil water then stop everything you're doing. Imagine if you were to put water into a pot, then as soon as you put it onto the stove you stood still and did absolutely nothing until it boiled?

That is basically synchronous/blocking code.

Instead you put the pot on, then you start putting butter/garlic on your bread. When you see the water boiling, you've been informed that it's ready for pasta.

The browser and node are doing this basically. It'll see some code, it'll register the event, then it goes on its merry way and does other stuff. When the event fires it figures out that it needs to do it.

A more technical example would be making a pretty big database call. You wouldn't want the the entire thread to be blocked during this call.

With asynchronous code you could run your db query and have an event that fires on "complete". This way the application is free to do other things. When the query finally finishes, it'll go back and run your callback.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-08-2011 , 03:11 PM
Quote:
Originally Posted by Shoe Lace
The browser and node are doing this basically. It'll see some code, it'll register the event, then it goes on its merry way and does other stuff. When the event fires it figures out that it needs to do it.
.
Thanks, but I think you misunderstood my question (which rereading is not really clear). I understand the concept at a high level; I am asking how the above is implemented with only a single thread. That is, you "register" an event, but since there is only one thread how does an event "fire". Is the single thread "checking" if event X fired every Y milliseconds or something? Or is the event "firing" handled by different threads at the OS/browser level, which then communicate the firing to the js thread?

That is, you have some main single thread doing stuff and executing on event listeners when events fire. But what is handling the firing itself?
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-08-2011 , 05:47 PM
Quote:
Originally Posted by gaming_mouse
I am asking how the above is implemented with only a single thread.
When I think "event loop", I think it implies that there's a loop running constantly, then as you add/remove events they get pushed/popped from an event queue.

You'll probably have better luck Googling for the specifics on how an event loop works at the lowest level.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
06-11-2011 , 01:56 AM
Sorry, haven't been keeping up this thread. I took a day off from programming yesterday, which is probably the first time I did that in over a month. Well, not really. I put up a few pages on the site, but it was mostly mindless copy/paste then change a few words stuff.

I think the next project is to go through each of the new CSS(3) attributes and see what is possible with them. So, look forward to a bunch of jsFiddle stuff.

Since I'm working through the MIT OpenCourse right now, I'll probably do the homework dual-core style: do the homework in the original language (Python in this case) and then in javascript. I think that'll be an interesting exercise.

If you wonder why I am doing Python, it is because their intro to programming is in Python. I sort of appreciate this approach, since Python does not have a daunting syntax. Regardless, the rest of the classes appear to use a combination of Python and Java, so it'll get interesting soon.
HTML5/CSS3/advancedJavascript learning and programming logs Quote
HTML5/CSS3/advancedJavascript learning and programming logs
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
HTML5/CSS3/advancedJavascript learning and programming logs

      
m