This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available in Web Workers.
The multiply() method of the DOMMatrixReadOnly interface creates and returns a new matrix which is the dot product of the matrix and the otherMatrix parameter. If otherMatrix is omitted, the matrix is multiplied by a matrix in which every element is 0 except the bottom-right corner and the element immediately above and to its left: m33 and m34. These have the default value of 1. The original matrix is not modified.
To mutate the matrix as you multiply it, see DOMMatrix.multiplySelf().
multiply() multiply(otherMatrix)
otherMatrix OptionalThe DOMMatrix multiplier.
A DOMMatrix.
const matrix = new DOMMatrixReadOnly().translate(13, 21); const multipliedMatrix = matrix.multiply(matrix); console.log(matrix.toString()); // output: matrix(1, 0, 0, 1, 13, 21) console.log(multipliedMatrix.toString()); // output: matrix(1, 0, 0, 1, 26, 42)
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
multiply |
61 | 79 | 33 | 48 | 11 | 61 | 33 | 45 | 11 | 8.0 | 61 | 11 |
DOMMatrix.multiplySelf()DOMMatrix.preMultiplySelf()matrix() functionmatrix3d() function
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrixReadOnly/multiply