diff --git a/samples/webgl/main.cpp b/samples/webgl/main.cpp
index 44206bb0cc..8f55322501 100644
--- a/samples/webgl/main.cpp
+++ b/samples/webgl/main.cpp
@@ -4,6 +4,7 @@
 
 #include <Message.hxx>
 #include <Message_Messenger.hxx>
+#include <Message_PrinterSystemLog.hxx>
 #include <OSD_MemInfo.hxx>
 #include <OSD_Parallel.hxx>
 
@@ -56,6 +57,8 @@ static void onFileReadFailed (void* theOpaque)
 int main()
 {
   Message::DefaultMessenger()->Printers().First()->SetTraceLevel (Message_Trace);
+  Handle(Message_PrinterSystemLog) aJSConsolePrinter = new Message_PrinterSystemLog ("webgl-sample", Message_Trace);
+  Message::DefaultMessenger()->AddPrinter (aJSConsolePrinter); // open JavaScript console within the Browser to see this output
   Message::DefaultMessenger()->Send (TCollection_AsciiString("NbLogicalProcessors: ") + OSD_Parallel::NbLogicalProcessors(), Message_Trace);
   aViewer.run();
   Message::DefaultMessenger()->Send (OSD_MemInfo::PrintInfo(), Message_Trace);
diff --git a/src/Message/Message_PrinterOStream.cxx b/src/Message/Message_PrinterOStream.cxx
index e28b23909b..ce7bb1ec35 100644
--- a/src/Message/Message_PrinterOStream.cxx
+++ b/src/Message/Message_PrinterOStream.cxx
@@ -243,6 +243,12 @@ void Message_PrinterOStream::SetConsoleTextColor (Standard_OStream* theOStream,
     }
     SetConsoleTextAttribute (anStdOut, aFlags);
   }
+#elif defined(__EMSCRIPTEN__)
+  // Terminal capabilities are undefined on this platform.
+  // std::cout could be redirected to HTML page, into terminal or somewhere else.
+  (void )theOStream;
+  (void )theTextColor;
+  (void )theIsIntenseText;
 #else
   if (theOStream == NULL)
   {
diff --git a/src/Message/Message_PrinterSystemLog.cxx b/src/Message/Message_PrinterSystemLog.cxx
index 8d2be63398..b87d4b410d 100644
--- a/src/Message/Message_PrinterSystemLog.cxx
+++ b/src/Message/Message_PrinterSystemLog.cxx
@@ -54,6 +54,35 @@
     }
     return ANDROID_LOG_DEBUG;
   }
+#elif defined(__EMSCRIPTEN__)
+  #include <emscripten/emscripten.h>
+
+  // actual version of Emscripten does not define these yet
+  #ifndef EM_LOG_INFO
+    #define EM_LOG_INFO 0
+  #endif
+  #ifndef EM_LOG_DEBUG
+    #define EM_LOG_DEBUG 0
+  #endif
+
+  //! Convert message gravity into emscripten_log() flags.
+  static int getEmscriptenPriority (const Message_Gravity theGravity)
+  {
+    switch (theGravity)
+    {
+      case Message_Trace:   return EM_LOG_CONSOLE | EM_LOG_DEBUG;
+      case Message_Info:    return EM_LOG_CONSOLE | EM_LOG_INFO;
+      case Message_Warning: return EM_LOG_CONSOLE | EM_LOG_WARN;
+      case Message_Alarm:   return EM_LOG_CONSOLE | EM_LOG_ERROR;
+      case Message_Fail:    return EM_LOG_CONSOLE | EM_LOG_ERROR;
+    }
+    return EM_LOG_CONSOLE;
+  }
+
+  //! Print message to console.debug().
+  EM_JS(void, debugMsgToConsole, (const char* theStr), {
+    console.debug(UTF8ToString(theStr));
+  });
 #else
   #include <syslog.h>
 
@@ -90,6 +119,8 @@ Message_PrinterSystemLog::Message_PrinterSystemLog (const TCollection_AsciiStrin
   myEventSource = (Standard_Address )RegisterEventSourceW (NULL, aWideSrcName.ToWideString());
 #elif defined(__ANDROID__)
   //
+#elif defined(__EMSCRIPTEN__)
+  //
 #else
   openlog (myEventSourceName.ToCString(), LOG_PID | LOG_NDELAY, LOG_USER);
 #endif
@@ -110,6 +141,8 @@ Message_PrinterSystemLog::~Message_PrinterSystemLog()
   }
 #elif defined(__ANDROID__)
   //
+#elif defined(__EMSCRIPTEN__)
+  //
 #else
   closelog();
 #endif
@@ -132,6 +165,15 @@ void Message_PrinterSystemLog::Send (const Standard_CString theString,
   Send (TCollection_ExtendedString (theString), theGravity, true);
 #elif defined(__ANDROID__)
   __android_log_write (getAndroidLogPriority (theGravity), myEventSourceName.ToCString(), theString);
+#elif defined(__EMSCRIPTEN__)
+  if (theGravity == Message_Trace)
+  {
+    debugMsgToConsole (theString);
+  }
+  else
+  {
+    emscripten_log (getEmscriptenPriority (theGravity), "%s", theString);
+  }
 #else
   syslog (getSysLogPriority (theGravity), "%s", theString);
 #endif
@@ -154,6 +196,15 @@ void Message_PrinterSystemLog::Send (const TCollection_AsciiString& theString,
   Send (TCollection_ExtendedString (theString), theGravity, true);
 #elif defined(__ANDROID__)
   __android_log_write (getAndroidLogPriority (theGravity), myEventSourceName.ToCString(), theString.ToCString());
+#elif defined(__EMSCRIPTEN__)
+  if (theGravity == Message_Trace)
+  {
+    debugMsgToConsole (theString.ToCString());
+  }
+  else
+  {
+    emscripten_log (getEmscriptenPriority (theGravity), "%s", theString.ToCString());
+  }
 #else
   syslog (getSysLogPriority (theGravity), "%s", theString.ToCString());
 #endif