Recent Posts


Magento 2: PrototypeJS Still Lurks


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

I was investigating Magento 2’s TinyMCE implementation the other day, and came across this

#File: vendor/magento//magento2-base/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js
], function(jQuery, _, tinyMCE) {

    tinyMceWysiwygSetup = Class.create();    

The TinyMCE RequireJS setup module was referencing a Class object – but there was no such object imported in the list of module dependencies.

I was flummoxed as to where this came from for a few minutes – did I miss some modern javascript addition where classes are something more than an alias to a function constructor?

Then I looked again at the list of RequireJS dependencies and saw this


A quick search through the requirejs-config.js files revealed this was an alias for the legacy-build.min module

45:        "prototype": "legacy-build.min",

and peek at that module’s source revealed –

#File: vendor/magento/magento2-base/lib/web/legacy-build.min.js
var Prototype={Version:"1.7",Browser:...

a minified version of PrototypeJS, which defines a globally available Class object.

As a programmer, I actually like Javascript. It’s a small language, with an interesting non-class based object system, and powerful first-class-functions that support closure.

As a developer though, dealing with the variety of different userland created object systems within the same project can be a bit maddening.

Copyright © Alan Storm 1975 – 2023 All Rights Reserved

Originally Posted: 16th June 2016