1

for test purposes I have removed nearly all the Javascript, except some inline Js which was not added in the page.xml. The Shop functionality is somehow broken now, because I cannot add Item to my Cart any more and the console tells me:

ReferenceError: setLocation is not defined

next to other errors which occur because some Javscript is missing. However I would like to limit the usage of Javascript to the absolute minimum needed. Magento uses Prototype and scriptaculous as standard libraries which is a bad choice, from my Point of View, so I do not want to have it on my Page.

Does Magento depend on some Javascript functionality in order to work correctly?

3
  • Working as expected when you strip out functionality for no good reason. Most modern web applications depend on one framework or another and the path to madness starts with expecting otherwise. No javascript, no backend. You might want to look elsewhere for your webshop software if this is such a major necessity. It's doubtful you have the expertise to rewrite Magento to not use Prototype. Others have tried... and failed. Commented Nov 23, 2013 at 2:02
  • Thanks for this reply! All I wanted to know was if magento can work safely as pure URL based web application, with the classic style of reload each page without any fancy Javascript UI functions. Commented Nov 23, 2013 at 12:33
  • Things like cookies work without Javascript, so I just ask myself If why this kind of code is necessary. Security concerns state that it is not good Idea to reply on Javascript validation and other stuff, so double checking everything on serverside is needed anyway. Commented Nov 23, 2013 at 12:39

3 Answers 3

3

As your Question seems to be "All I wanted to know was if magento can work safely as pure URL based web application, with the classic style of reload each page without any fancy Javascript UI functions."

Short answer: No its not possible.

Long answer: Yes, but you have to know a lot and you need to build a theme which works without javascript (I explain this in more details a bit below) also its possible, that you need to rebuild some parts of the checkout, which relays heavy on javascript.

So, what is Magento using the javascript for:

  1. Design
    Magento was build to support browsers back to IE6, for having more choices with css, like styling .first and .last elements, is uses javascript to fill some css classes into the finished html.

  2. Validation
    As you noted above, js validation should not part of the security, as you can workaround it. Thats why magento still validates on server side. But: Javascript validation gives nicer error messages and reduces the http requests made, as people send mostly no wrong data as javascript validation prevents this. It makes the whole usage flow more fluent.

  3. Product Pages
    Main Point here, is the price block. If you change options, this should reflect on the price block, to make it more easy for customers to see price changes. If you want this without javascript, you would need to create a big list with all possible option combinations and their prices.

  4. MSRP - Manufacturer’s Suggested Retail Price
    Never used this, but there is some option, to show this price only when you click on something.

  5. Address fields
    You chose your region depending on the selected Country. This could be very ugly without javascript. Think about it.

  6. The whole Admin area
    but as you only removed it for frontend, this is no point here. But yeah, I dont think the admin area is possible to get working without javascript. Way to many architectual decisions which depend on Javascript here.

  7. Checkout
    Yeah, Checkout is mostly javascript. Biggest part is the former mentioned Address fields. Iam not sure, with a lot of template work the rest should be possible without javascript

  8. Payment methods
    except them. Every payment method of an external service (paypal, Credit Card, Google, Amazone) depends on javascript.

Summary:
Every javascript functionality depends on a base framework, so they dont need to rebuild 60% from scratch for every usecase. Because of this, you will have no real gain, if you deactivate the framework on the base, and selectively activate it, where you still use js.

Also there is no really downside to use javascript, only very few people have javascript deactivated. Most people today are more selective and use extra extensions to deactivate advertisements and tracking scripts.

0
0

The function you are missing is defined in js/varien/js.js (and js/mage/adminhtml/tools.js for backend).
You shouldn't remove any js file. They are there for a reason.
If you consider prototype a bad choise and you want to replace it with something else, you may need to do a lot of coding to make your theme completely independent of prototype. And to answer your question

Does Magento depend on some Javascript functionality in order to work correctly?

Yes, it does. JS is an important part of Magento (and for any modern website for that mater).

-1

The checkout process (onepage) need Prototype, without it the onepage checkout process won't work. You will find that in: /skin/frontend/default/YOURTHEME/js/opcheckout.js.

You can disable the onepage and take another checkout process

System->Configuration, Click on Checkout under SALES you find Checkout Options

I am not sure if other checkout systems need Javascript. But in the end, Magento was build with Prototype. That means to change that to another JSlib like jQuery would be a ton of work.

There are others that wish prototype away: http://magento.uservoice.com/forums/24441-magento-ecommerce-platform/suggestions/280904-switch-from-prototype-to-jquery

And if I am right prototype is removed in Magento 2! So you have to wait, but it will come: http://openjudo.com/jquery-in-magento-2/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.