How to overwrite a JavaScript core function?

You can’t.

While manipulation of JS and HTML is possible, it is not adviceable as a long term strategy unless it was explicitly document as “the right way” in the codex, code comment, or some other core document.

In addition to the theoretical objection, right now it is hard or almost impossible to override specific JS core functions without resorting to dequeuing core files and enqueuing your version which in practice do not eliminate the need to follow up with changes to the core file and re implementing your changes with every version that changes the core file.

Your best option is probably to open a ticket on trac, explain that the change is breaking your code and why you don’t have any other alternative. This will probably not help you with 4.3.1 but you might get either a better suggestion on how to do what you need without hacking the core, and maybe have the offending code reverted for 4.4.

Leave a Comment