JavaScript MVC frameworks are booming, but this post may change your mind about them. Before I explain to you the ten very good reasons to stop using JavaScript, I will first list a few popular JavaScript MVC frameworks:
Image may be NSFW.
Clik here to view.
- We start with one of the most well known frameworks, Backbone.js. With Backbone, your data is represented in Models.
- Second is Ember.js. Whilst Backbone is fairly low level, with a lot of code that you need to write yourself, such as code to update the view when model data changes, Ember does a lot of that work for you.
- Next up is Google’s offering, the relatively new Angular.js. Angular takes a slightly different approach by doing data binding directly in your HTML.
- Knockout.js is an MVVM (Model-View-View Model) framework written in pure JavaScript. MVVM frameworks are split into three parts.
- Finally, I wanted to pick something different to all of the above and went with Batman.js, and not only because of the name.
Source: JavaScript MVC framework top 5
Now brace for the 10 very good reasons to stop using JavaScript:
1. JavaScript hurts your mobile visitors
Yes, you heard me right! Do you think that 600 Mhz CPU of the mobile device used to visit your site will execute the 10.000 lines of JavaScript you added (or linked) in your page? It does, but your visitors won’t wait for it. And how much memory do you think your cleverly AJAX loaded DOM objects take in the browser memory? Try using the Google Chrome Heap Profiler and double-check your findings. You need to because they are that high.
You may want to read Who Is Murdering PhoneGap? It’s jQuery Mobile as a reference.
2. JavaScript hurts your robustness
A single bug in your JavaScript can break the functionality of your entire website. Especially when you are relying on one of the above MVC frameworks. And you cannot test against future browser implementations of JavaScript, can you now? I feel JavaScript should only be used to enhance a website. If it is not available or it fails, it should degrade gracefully. This means that your website should still work, albeit less conveniently or pretty. Even better is the related concept of progressive enhancement.
Oops. Firefox 18 broke my JavaScript-heavy website when no other version of FF did. This proves the point, right?
3. JavaScript hurts your security (and your privacy)
XSS and XSRF are the acronyms most web developers do not understand. Let’s keep it that way, because hackers and security consultants are making good money on them. No kidding, I think that knowledge about these subjects is much more important than your client-side script-fu. So if you are using JavaScript, but have no idea how to avoid these attacks, then please, for the sake of the web, stop using JavaScript (and start reading some security books). AJAX based content loading and form submission are often vulnerable to these kind of attacks. Also automated security tools often fail at detecting these issues, since they rely on HTML parsing, which is not possible when using AJAX.
Sure, you knew all about that, since you are very security aware. This video explaining XXXSS attacks is so awesome, that after seeing it you may be tempted to start using NoScript: a Firefox plugin that blocks all scripts on non-trusted sites.
4. JavaScript hurts your SEO
Yes, that is right, we are talking about Google’s almighty spiders that are not (good at) executing your JavaScript. This means that the JavaScript loaded parts of your website will not be indexed. This should not be a shock to you, since this is a well known fact. But it makes investing money in AdWords (for example, e-commerce) and using JavaScript a problematic combination. On the other hand you may be creating a website that is behind a pay-wall or a web application that requires authentication. In those cases the Google spider bots have no access anyway, so you don’t have to worry.
AJAX can make a site difficult for search engines to index if the technology is not implemented carefully. There are two main search engine issues around AJAX: making sure that search engine bots can see your content, and making sure they can see and follow your navigation.
This is not my opinion. I’m quoting Google’s advice on applying AJAX:
… view it in a text-only browser such as Lynx. Viewing a site as text-only can also help you identify other content which may be hard for Googlebot to see …
Try a text-only browser like “lynx” or “elinks” and you will be shocked by what Google will see!
5. JavaScript hurts your development time
Debugging JavaScripts can be a very tedious task. Especially when your JavaScript codebase is large and it is connected to many events on your DOM. It may be very hard to exactly find out how often and in what order events are happening. Also you have to rely on the debug tools provided by the browser. This is fine for a modern Firefox or Google Chrome, but how about old Internet Explorers? How many hours did you waste on that, honestly?
Testing cross-browser and cross-platform is expensive because of the numerous combinations possible. This form of testing is needed, because implementations differ, since there is no JavaScript standard.
6. JavaScript hurts your testing costs
Test driven development often relies on functional tests executed by test robots (much like Google’s spider bots). This form of automated testing relies on parsing the generated HTML. But JavaScript applications cannot be tested without the actual use of a browser, causing the testing to become very complicated and expensive. I have seen whole server farms being setup to automate the testing of a web application in different browsers on different operating systems. And the costs are not only in building such a setup, you should be mainly concerned about its maintenance costs.
The “Selenium Grid” approach is good but costly. It is well described in “Headless Functional Testing with Selenium and PhantomJS”.
7. JavaScript hurts your website performance
Lots of people are using AJAX to load multiple parts of their website in separate requests. Where you normally have one request for the HTML, the web server now handles multiple requests for HTML from the browser. That way the web browser is tricked into thinking that the website is loaded after the first request of HTML. This allows the visitor to look at something (which according to some UX guru’s is important), but it will slow down the actual loading of the website. It is even worse if you consider that this behavior will put a higher strain on your web server, resulting in slower serving of the page during peak hours (when it matters most).
Also interesting to read is that JavaScript may slow down your website due to poor JavaScript performance.
8. JavaScript hurts your software investment
Client-side technology is doomed to fail. We have seen Java applets fail. Then we’ve seen Flash fail (under suspicious circumstances). If history repeats itself (and it mostly does), JavaScript will fail as well, since it is the third in it’s kind. When exactly is still unsure, but investing a lot of money in a codebase built on such an uncertain platform seems like a huge risk to me.
9. JavaScript hurts your software architecture
The reason the above MVC frameworks are on the rise is easy, there is no good way to write substantial software in JavaScript. The lack of any traditional OOP structures drives programmers mad. MooTools tries to fill that gap by providing just that. A good try, but it is still a hack that is lacking a lot of core OOP principles. These things frustrate professional and experienced programmers, since they are simply not used to write in functional languages. How many programmers that have a professional education actually know how to do functional programming? And how many are good at it?
JavaScript is sexy describes very thoroughly, how to apply the OOP paradigm in a classless (prototype-based) scripting language.
10. JavaScript is not needed
Yes, you can create websites and applications without JavaScript. Everything that is possible in JavaScript can be done on the server side. But this is not how we roll, right? We need “new” and “cool” technology don’t we? Otherwise we (web developers) would be bored. But I ask you, can you look your boss straight in the eyes arguing that you “need JavaScript”? Is there a valid business case? Does this technology really pay off?
A lot of web development is done on applications that consist of lists, forms and buttons (administrative applications). Those applications definitely do not need JavaScript. People creating games or other real-time experiences, may consider themselves lucky, they are excepted.
Convinced?
Great! Not convinced? And you think I am a JavaScript hater? Well, I am not. I am the author of the extensive MinJS.org JavaScript MVC web framework.
The post 10 very good reasons to stop using JavaScript appeared first on LeaseWeb Labs.