I have used JavaScript since it was called LiveScript,
and know to value persons who say "Eval is Evil"
(Classic SharePoint uses eval() at least 5 times in its core code)

So when a new kid on the block gets (a bit) Evil,
starts telling you how to behave,
and restricts your capabilities,
😇 you counter it with Creativity:

  this.domElement.innerHTML = eval(
      `var s=document.createElement("SCRIPT");


  • Can we safely use standard ECMAscript eval() in SPFX?

  • There are ways of crippling eval();
    as Classic SharePoint uses eval itself in its core code,
    will SPFx / New Experience not be more Evil on us?

  • Is eval used in new SharePoint code?
    Haven't had time yet to do a code analysis...
    Seems kinda pointless with an update every couple of weeks:

    (script:0 is my auto-check if UserCustomActions are enabled again)

  • Clever title, but not sure what you're asking here... – SPDoctor Aug 26 '16 at 9:14
  • Question: can I safely use standard eval() in SPFx? – Danny '365CSI' Engelman Aug 26 '16 at 10:18
  • Okay can you edit the question so the title is clear, and just one question that maybe someone working on SPFx can answer. Thanks. – SPDoctor Aug 26 '16 at 10:25
  • This is probably gonna end up a Community question anyway, as there won't be a definite right/wrong answer, more likely just an overwhelming "No, don't do that. You can, but there's probably better way". – James Love Aug 30 '16 at 8:42
  • Would you mind explaining what you mean by "restrict your capabilities", (why you need a workaround)? – Christophe Oct 27 '16 at 15:16

I.believe you can use it. As you mention its generally not a good practice, but you can use it. I don't believe we use it in any of our code. Are you encountering any issue?

| improve this answer | |
  • 2
    Honestly I don't like this answer. You can't make such a statement on the safety of eval without knowing the details of the implementation and the reasons behind it. – Christophe Oct 27 '16 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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