diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 21c1d9d670d65..6c6c067f95189 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -49,6 +49,13 @@
var themesWidth = null;
+ if (!String.prototype.startsWith) {
+ String.prototype.startsWith = function(searchString, position) {
+ position = position || 0;
+ return this.indexOf(searchString, position) === position;
+ };
+ }
+
function hasClass(elem, className) {
if (elem && className && elem.className) {
var elemClass = elem.className;