Chess AI Using Minimax and Alpha-Beta Pruning

I am working on a Chess AI using chess.js, and currently, it can run 3 layers in under 10 seconds, but 4 or more takes minutes. How can I optimize my current code to be able to run 4 or 5 layers, or do I have to implement a different algorithm.

Here is my code:

function startMinimax(depth, game, isMaximisingPlayer) {   var moves = game.moves({ verbose: true });   var bestEval = -9999;   var bestMove;   for (var i = 0; i < moves.length; i++) {     var move = moves[i];     game.move(move);     var value = minimax(depth - 1, game, -10000, 10000, !isMaximisingPlayer);     game.undo();     if (value >= bestEval) {       bestEval = value;       bestMove = move;     }   }   return bestMove; }  function minimax(depth, game, alpha, beta, isMaximisingPlayer) {   if (depth === 0) {     return -evaluateBoard(game);   }   var moves = game.moves({ verbose: true });    if (isMaximisingPlayer) {     var bestEval = -9999;     for (var i = 0; i < moves.length; i++) {       game.move(moves[i]);       bestEval = Math.max(bestEval, minimax(depth - 1, game, alpha, beta, !isMaximisingPlayer));       game.undo();       alpha = Math.max(alpha, bestEval);       if (beta <= alpha) {         return bestEval;       }     }     return bestEval;   } else {     var bestEval = 9999;     for (var i = 0; i < moves.length; i++) {       game.move(moves[i]);       bestEval = Math.min(bestEval, minimax(depth - 1, game, alpha, beta, !isMaximisingPlayer));       game.undo();       beta = Math.min(beta, bestEval);       if (beta <= alpha) {         return bestEval;       }     }     return bestEval;   } } 

If $(\alpha,\beta)$ is the factor pair congruences of algebra $\mathbb{A},$ ia $(\forall \gamma\in ConA)\alpha\circ\gamma=\gamma\circ\beta?$

Let $ \mathbb{A}$ be an algebra such that $ ConA$ is the distributive lattice. If $ (\alpha,\beta)$ is the factor pair congruences of algebra $ \mathbb{A},$ prove that $ (\forall \gamma\in ConA)\alpha\circ\gamma=\gamma\circ\beta.$