I am using Magento2.4. In my phtml template, I am trying to escape an a argument that is being passed into a javascript file via requireJS, but PhpStorm is warning me that escapeJs() is depreciated. What would be the correct function to use if escapeJs() is depreciated?

1 Answer 1


In the block has $escaper already, you need to use that. Here is the example:

 * @var \Magento\Framework\Escaper $escaper

Now you can use:


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.