Jump to content

Javascript Vs. Php


pizzaguy

Recommended Posts

Hello there, I was wondering what the opinions were when it came to Javascript and PHP. Im planning on making a web gallery based on an XML document (it contains all of the image locations, names and descriptions and such), and I was wondering what would be better to use. My plan was to simply read and parse the XML document and generate the gallery. The javascript would leave the loading of the list (all that the gallery will be is a list of thumbnails) to the client and would probably be faster than the server reloading the page every time someone views it, but not everyone uses javascript. Are there any opinions on what would be better for this purpose?

Link to comment
Share on other sites

Thats what i was thinking. Is <noscript> valid in the <head> portion of a page (to redirect to a php page)?
I don't think what you're describing is what Ingolme had in mind.Create the page with PHP first. In the resulting (X)HTML from PHP, add some JavaScript that is going to take over the handling of the various links (Next, Previous, etc.). If the user has JavaScript enabled, they're going to see the JavaScript behaviour. Without it, they'll be clicking on normal links that are going to retrigger PHP with new parameters.Forget about <noscript>. Some proxies strip out JavaScript, but that doesn't mean users have it disabled. The combination of those two factors means JavaScript doesn't get executed, and neither does <noscript>. There aren't any definite statistics, but I'm assuming a significant portion of PC JS-less users are exactly corporate users behind such proxies.
Link to comment
Share on other sites

I don't think what you're describing is what Ingolme had in mind.Create the page with PHP first. In the resulting (X)HTML from PHP, add some JavaScript that is going to take over the handling of the various links (Next, Previous, etc.). If the user has JavaScript enabled, they're going to see the JavaScript behaviour. Without it, they'll be clicking on normal links that are going to retrigger PHP with new parameters.Forget about <noscript>. Some proxies strip out JavaScript, but that doesn't mean users have it disabled. The combination of those two factors means JavaScript doesn't get executed, and neither does <noscript>. There aren't any definite statistics, but I'm assuming a significant portion of PC JS-less users are exactly corporate users behind such proxies.
Well that wont work because my plan was to use javascript (or PHP) to generate the links in the first place. the noscript was just my idea to put this in the head
<noscript><meta http-equiv="refresh" content="5;url=index_alt.php"></meta></noscript>

Link to comment
Share on other sites

I don't see a reason to redirect to a PHP page. You can just put the PHP code right in the same page. You can update it using AJAX, and when Javascript is disabled the links will reload the page instead.

Link to comment
Share on other sites

Wy should a normal user disable Javascript that's just non-sense. Only web-proxies do it so the user client doesn't get their ip revealed. So i should go for javascript with Ajax. Also when using javascript not the whole page needs to be loaded from the server again, only the XML documents containing the images or whatever.

Link to comment
Share on other sites

Wy should a normal user disable Javascript that's just non-sense. Only web-proxies do it so the user client doesn't get their ip revealed. So i should go for javascript with Ajax. Also when using javascript not the whole page needs to be loaded from the server again, only the XML documents containing the images or whatever.
I always develop the server-side method first and then override it with Javascript. I do care about the people who have Javascript disabled. It's just developing it in Javascript and having an alternate method that works when Javascript is disabled.
Link to comment
Share on other sites

Wy should a normal user disable Javascript that's just non-sense.
That's like asking why the rain falls. It doesn't matter why it falls. It does does, and if you don't weather-proof your house, you'll be sleeping in the mud. Same thing here. People do disable Javascript. You don't have to like it. But you might want to prepare for it.Keep in mind there is a huge class of users who do not control the computers they use. This includes university students, library users, and many people who work for corporations that keep tight control on their networks.
Link to comment
Share on other sites

People do disable Javascript. You don't have to like it. But you might want to prepare for it.
The vast majority of people who have Javascript disabled did it themselves, probably using noscript. Those people know enough to enable it again for my site, if they don't want to do it, fine, they don't have to use my site. So I guess it depends what kind of site you're trying to set up. If you're trying to attract as many people as possible and make sure that everyone can use your site, Javascript may not be the best choice to require. If you're setting up a service where you don't really care how many people use it, where it's on your terms, requiring Javascript is perfectly acceptable. If people want to use your service, they enable Javascript.
Keep in mind there is a huge class of users who do not control the computers they use. This includes university students, library users, and many people who work for corporations that keep tight control on their networks.
I understand that in concept, but in my work we've got several Javascript-heavy applications and we work with several large government and corporate organizations. We've seen a lot of various problems that people have had using our stuff, but disabling or stripping out Javascript hasn't been one of them. I'm not saying companies don't do that, I've just never seen one that does.
Link to comment
Share on other sites

My bigger projects are likewise Javascript dependent, and users know that coming in, or they don't come in.On this board, however, we see folks who might unwittingly make it impossible to move from page 1 to page 2 without Javascript. I would have hated for Post #7 to convince naive scriptors that you can always ignore the Javascript-impaired.

Link to comment
Share on other sites

That's a good point.It's not about ignoring people without Javascript, it's more about recognizing that some people have it disabled, and making a conscious decision whether you want those people to be able to use your site.Just like I said that several applications I've got require Javascript, I'm working on something else where it does use a lot of ExtJS, but it's set up so that search engines can still find everything and should generally be usable without Javascript, it will just look fugly. But that project has a much bigger need to appeal to the general public than the other applications do.

Link to comment
Share on other sites

Well that wont work because my plan was to use javascript (or PHP) to generate the links in the first place. the noscript was just my idea to put this in the head
<noscript><meta http-equiv="refresh" content="5;url=index_alt.php"></meta></noscript>

Then use PHP to generate them in the first place. But as far as performance is concerned, you can use JavaScript on top of that to improve it by only updating the image, not the whole page.
I don't see a reason to redirect to a PHP page. You can just put the PHP code right in the same page. You can update it using AJAX, and when Javascript is disabled the links will reload the page instead.
My point exactly. :)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...