Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantages / Disadvantages to websites generated with Javascript

Two good examples would be google and facebook.

I have lately pondered the motivation for this approach. My best guess would be it almost completely separates the logic between your back-end language and the markup. Building up an array to send over in JSON format seems like a tidy way to maintain code, but what other elements am I missing here?

What are the advantages / disadvantages to this approach, and why are such large scale companies doing it?

like image 359
grep Avatar asked Mar 24 '12 18:03

grep


People also ask

Which disadvantage affects web pages created using JavaScript?

Client-Side Security - Since JavaScript code is executed on the client-side, bugs and oversights can sometimes be exploited for malicious purposes. Because of this, some people choose to disable JavaScript entirely.

Why is JavaScript good for websites?

js makes responsive design easier. JavaScript has become integral to the Internet experience as developers build increased interaction and complexity into their applications. Search engines, ecommerce, content management systems, responsive design, social media and phone apps would not be possible without it.

What do you think is the biggest disadvantage of using JavaScript?

The main problem or disadvantage in JavaScript is that the code is always visible to everyone anyone can view JavaScript code. No matter what proportion fast JavaScript interpret, JavaScript DOM (Document Object Model) is slow and can be a never fast rendering with HTML.


2 Answers

The main disadvantage is that you have some pain with content indexation of your site.

For Google you can somewhere solve the problem by using Crawling scheme. Google supports crawling that allows you to index dynamically (without page reload) generated content of your page.

To do this your virtual links must be addresses like so: http://yoursite.com/#!/register/. In this case Google requests to http://yoursite/register/ to index content of the address.

When clicking on virtual link there is no page reload. You can provide this by using onclick:

<a href='http://yoursite.com/#!/register/' onclick='showRegister()'>Register</a>

Virtual advantage is that content of a page changed without reloading of the page. In my practice I do not use Javascript generation to do this because I build my interface in fixed positions. When page reloads user does not notice anything because elements of the interface appears in expected places.

So, my opinion that using of dynamic page generation is a big pain. I think Google did it not to separate markup and backend (it's not a real problem, you can use complex structure of backend-frontend to do that) but to use advantages of convenient and nice representation for users.

like image 69
sergzach Avatar answered Oct 21 '22 21:10

sergzach


Advantages

  • View state is kept on the client (removing load from the server)
  • Partial refreshes of pages
  • Server does not need to know about HTML which leads to a Service Oriented Architecture

Disadvantages

  • Bookmarking (state in the URL) is harder to implement
  • Making it searchable is still a work in progress
  • Need a separate scheme to support non-JS users
like image 27
Juan Mendes Avatar answered Oct 21 '22 22:10

Juan Mendes