Index: ex_docmd.c
===================================================================
--- ex_docmd.c	(revision 1682)
+++ ex_docmd.c	(working copy)
@@ -245,6 +245,10 @@
 # define ex_mzscheme		ex_script_ni
 # define ex_mzfile		ex_ni
 #endif
+#ifndef FEAT_JS
+# define ex_js		        ex_script_ni
+# define ex_jsfile		ex_ni
+#endif
 #ifndef FEAT_PERL
 # define ex_perl		ex_script_ni
 # define ex_perldo		ex_ni
Index: ex_cmds.h
===================================================================
--- ex_cmds.h	(revision 1682)
+++ ex_cmds.h	(working copy)
@@ -617,6 +617,8 @@
 			RANGE|EXTRA|DFLALL|NEEDARG|CMDWIN|SBOXOK),
 EX(CMD_mzfile,		"mzfile",	ex_mzfile,
 			RANGE|FILE1|NEEDARG|CMDWIN),
+EX(CMD_jsfile,		"jsfile",	ex_jsfile,
+			RANGE|FILE1|NEEDARG|CMDWIN),
 EX(CMD_next,		"next",		ex_next,
 			RANGE|NOTADR|BANG|FILES|EDITCMD|ARGOPT|TRLBAR),
 EX(CMD_nbkey,		"nbkey",	ex_nbkey,
Index: configure.in
===================================================================
--- configure.in	(revision 1682)
+++ configure.in	(working copy)
@@ -633,6 +633,27 @@
 AC_SUBST(PERL_CFLAGS)
 AC_SUBST(PERL_LIBS)
 
+
+AC_MSG_CHECKING(--enable-jsinterp argument)
+AC_ARG_ENABLE(jsinterp,
+	[  --enable-jsinterp   Include Javascript interpreter.], ,
+	[enable_jsinterp="no"])
+AC_MSG_RESULT($enable_jsinterp)
+if test "$enable_jsinterp" = "yes"; then
+    AC_DEFINE(FEAT_JS)
+    JS_SRC=if_js.c
+    JS_PRO=if_js.pro
+    JS_OBJ=objects/if_js.o
+    JS_LIBS="-L/usr/local/lib -lmozjs  -ldl -lm  -lm -ldl "
+    JS_CFLAGS="-I/usr/local/include/js"
+fi
+AC_SUBST(JS_LIBS)
+AC_SUBST(JS_CFLAGS)
+AC_SUBST(JS_SRC)
+AC_SUBST(JS_OBJ)
+AC_SUBST(JS_PRO)
+
+
 AC_MSG_CHECKING(--enable-pythoninterp argument)
 AC_ARG_ENABLE(pythoninterp,
 	[  --enable-pythoninterp   Include Python interpreter.], ,
Index: config.mk.in
===================================================================
--- config.mk.in	(revision 1682)
+++ config.mk.in	(working copy)
@@ -67,6 +67,12 @@
 TCL_CFLAGS	= @TCL_CFLAGS@
 TCL_LIBS	= @TCL_LIBS@
 
+JS_SRC		= @JS_SRC@
+JS_OBJ		= @JS_OBJ@
+JS_PRO		= @JS_PRO@
+JS_CFLAGS	= @JS_CFLAGS@
+JS_LIBS	= @JS_LIBS@
+
 HANGULIN_SRC	= @HANGULIN_SRC@
 HANGULIN_OBJ	= @HANGULIN_OBJ@
 
Index: feature.h
===================================================================
--- feature.h	(revision 1682)
+++ feature.h	(working copy)
@@ -1174,6 +1174,7 @@
  * +perl		Perl interface: "--enable-perlinterp"
  * +python		Python interface: "--enable-pythoninterp"
  * +tcl			TCL interface: "--enable-tclinterp"
+ * +js                  JavaScript interface: "--enable-jsinterp"
  * +sniff		Sniff interface: "--enable-sniff"
  * +sun_workshop	Sun Workshop integration
  * +netbeans_intg	Netbeans integration
@@ -1277,3 +1278,5 @@
 	    || defined(FEAT_BIG)
 # define FEAT_AUTOCHDIR
 #endif
+
+#define FEAT_JS
Index: main.aap
===================================================================
--- main.aap	(revision 1682)
+++ main.aap	(working copy)
@@ -243,13 +243,13 @@
 
 
 PRE_DEFS = -Iproto -I. $DEFS $GUI_DEFS $GUI_IPATH $CPPFLAGS $?(EXTRA_IPATHS)
-POST_DEFS = $X_CFLAGS $MZSCHEME_CFLAGS $PERL_CFLAGS $PYTHON_CFLAGS $TCL_CFLAGS $RUBY_CFLAGS $?(EXTRA_DEFS)
+POST_DEFS = $X_CFLAGS $MZSCHEME_CFLAGS $PERL_CFLAGS $JS_CFLAGS $PYTHON_CFLAGS $TCL_CFLAGS $RUBY_CFLAGS $?(EXTRA_DEFS)
 CFLAGS = $PRE_DEFS $CONF_CFLAGS $?(PROFILE_CFLAGS) $POST_DEFS
 CPPFLAGS =
 
 ALL_LIB_DIRS = $GUI_LIBS_DIR $X_LIBS_DIR
 LDFLAGS = $ALL_LIB_DIRS $CONF_LDFLAGS
-LIBS = $GUI_LIBS1 $GUI_X_LIBS $GUI_LIBS2 $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $CONF_LIBS $?(EXTRA_LIBS) $MZSCHEME_LIBS $PERL_LIBS $PYTHON_LIBS $TCL_LIBS $RUBY_LIBS $?(PROFILE_LIBS)
+LIBS = $GUI_LIBS1 $GUI_X_LIBS $GUI_LIBS2 $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $CONF_LIBS $?(EXTRA_LIBS) $MZSCHEME_LIBS $PERL_LIBS $JS_LIBS $PYTHON_LIBS $TCL_LIBS $RUBY_LIBS $?(PROFILE_LIBS)
 
 Target = $VIMNAME
 
@@ -345,6 +345,7 @@
         $RUBY_SRC
         $SNIFF_SRC
         $WORKSHOP_SRC
+        $JS_SRC
 
 Objects =
         $GUI_OBJ
Index: main.c
===================================================================
--- main.c	(revision 1682)
+++ main.c	(working copy)
@@ -197,6 +197,10 @@
     vim_tcl_init(params.argv[0]);
 #endif
 
+#ifdef FEAT_JS
+    vim_js_init(params.argv[0]);
+#endif
+
 #ifdef MEM_PROFILE
     atexit(vim_mem_profile_dump);
 #endif
@@ -1345,6 +1349,9 @@
 #ifdef FEAT_PYTHON
     python_end();
 #endif
+#ifdef FEAT_JS
+    js_end();
+#endif
 #ifdef FEAT_PERL
     perl_end();
 #endif
Index: proto.h
===================================================================
--- proto.h	(revision 1682)
+++ proto.h	(working copy)
@@ -167,6 +167,10 @@
 #  include "if_python.pro"
 # endif
 
+# ifdef FEAT_JS
+#  include "if_js.pro"
+# endif
+
 # ifdef FEAT_TCL
 #  include "if_tcl.pro"
 # endif
Index: config.aap.in
===================================================================
--- config.aap.in	(revision 1682)
+++ config.aap.in	(working copy)
@@ -51,6 +51,12 @@
 TCL_CFLAGS	= @TCL_CFLAGS@
 TCL_LIBS	= @TCL_LIBS@
 
+JS_SRC		= @JS_SRC@
+JS_OBJ		= @JS_OBJ@
+JS_PRO		= @JS_PRO@
+JS_CFLAGS	= @JS_CFLAGS@
+JS_LIBS	= @JS_LIBS@
+
 HANGULIN_SRC	= @HANGULIN_SRC@
 HANGULIN_OBJ	= @HANGULIN_OBJ@
 
Index: Makefile
===================================================================
--- Makefile	(revision 1682)
+++ Makefile	(working copy)
@@ -1302,7 +1302,7 @@
 .SUFFIXES: .c .o .pro
 
 PRE_DEFS = -Iproto $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS)
-POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(TCL_CFLAGS) $(RUBY_CFLAGS) $(EXTRA_DEFS)
+POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(JS_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(TCL_CFLAGS) $(RUBY_CFLAGS) $(EXTRA_DEFS)
 
 ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(POST_DEFS)
 
@@ -1322,7 +1322,7 @@
 PFLAGS = $(PROTO_FLAGS) -DPROTO $(LINT_CFLAGS)
 
 ALL_LIB_DIRS = $(GUI_LIBS_DIR) $(X_LIBS_DIR)
-ALL_LIBS = $(GUI_LIBS1) $(GUI_X_LIBS) $(GUI_LIBS2) $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS) $(LIBS) $(EXTRA_LIBS) $(MZSCHEME_LIBS) $(PERL_LIBS) $(PYTHON_LIBS) $(TCL_LIBS) $(RUBY_LIBS) $(PROFILE_LIBS)
+ALL_LIBS = $(GUI_LIBS1) $(GUI_X_LIBS) $(GUI_LIBS2) $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS) $(LIBS) $(EXTRA_LIBS) $(MZSCHEME_LIBS) $(JS_LIBS) $(PERL_LIBS) $(PYTHON_LIBS) $(TCL_LIBS) $(RUBY_LIBS) $(PROFILE_LIBS)
 
 # abbreviations
 DEST_BIN = $(DESTDIR)$(BINDIR)
@@ -1424,13 +1424,13 @@
 	$(OS_EXTRA_SRC)
 
 SRC =	$(BASIC_SRC) $(GUI_SRC) $(HANGULIN_SRC) $(MZSCHEME_SRC) \
-	$(PERL_SRC) $(PYTHON_SRC) $(TCL_SRC) $(RUBY_SRC) \
+	$(JS_SRC) $(PERL_SRC) $(PYTHON_SRC) $(TCL_SRC) $(RUBY_SRC) \
 	$(SNIFF_SRC) $(WORKSHOP_SRC) $(WSDEBUG_SRC)
 
 TAGS_SRC = *.c *.cpp if_perl.xs
 
 EXTRA_SRC = hangulin.c if_mzsch.c auto/if_perl.c if_perlsfio.c \
-	    if_python.c if_tcl.c if_ruby.c if_sniff.c gui_beval.c \
+	    if_python.c if_tcl.c if_js.c if_ruby.c if_sniff.c gui_beval.c \
 	    workshop.c wsdebug.c integration.c netbeans.c
 
 # All sources, also the ones that are not configured
@@ -1496,6 +1496,7 @@
 	$(GUI_OBJ) \
 	$(MZSCHEME_OBJ) \
 	$(PERL_OBJ) \
+	$(JS_OBJ) \
 	$(PYTHON_OBJ) \
 	$(TCL_OBJ) \
 	$(RUBY_OBJ) \
@@ -1558,7 +1559,9 @@
 	workshop.pro \
 	netbeans.pro \
 	$(ALL_GUI_PRO) \
-	$(TCL_PRO)
+	$(TCL_PRO) \
+	$(JS_PRO)
+	
 
 # Resources used for the Mac are in one directory.
 RSRC_DIR = os_mac_rsrc
@@ -1586,7 +1589,7 @@
 		LDFLAGS="$(LDFLAGS)" $(CONF_SHELL) srcdir="$(srcdir)" \
 		./configure $(CONF_OPT_GUI) $(CONF_OPT_X) $(CONF_OPT_XSMP) \
 		$(CONF_OPT_DARWIN) $(CONF_OPT_PERL) $(CONF_OPT_PYTHON) \
-		$(CONF_OPT_TCL) $(CONF_OPT_RUBY) $(CONF_OPT_NLS) \
+		$(CONF_OPT_TCL) $(CONF_OPT_JS) $(CONF_OPT_RUBY) $(CONF_OPT_NLS) \
 		$(CONF_OPT_CSCOPE) $(CONF_OPT_MULTIBYTE) $(CONF_OPT_INPUT) \
 		$(CONF_OPT_OUTPUT) $(CONF_OPT_GPM) $(CONF_OPT_WORKSHOP) \
 		$(CONF_OPT_SNIFF) $(CONF_OPT_FEAT) $(CONF_TERM_LIB) \
@@ -2452,6 +2455,9 @@
 objects/if_ruby.o: if_ruby.c
 	$(CCC) -o $@ if_ruby.c
 
+objects/if_js.o:  if_js.c
+	$(CCC) -o $@ if_js.c
+
 objects/if_sniff.o: if_sniff.c
 	$(CCC) -o $@ if_sniff.c
 
@@ -2945,6 +2951,10 @@
   auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
   regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
   globals.h farsi.h arabic.h
+objects/if_js.o: if_js.c vim.h auto/config.h feature.h os_unix.h \
+  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+  globals.h farsi.h arabic.h
 objects/if_tcl.o: if_tcl.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
   ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
   gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \

Index: if_js.c
===================================================================
--- if_js.c	(revision 0)
+++ if_js.c	(revision 0)
@@ -0,0 +1,162 @@
+/*
+ * vi:set ts=8 sw=4: VIM - Vi IMproved	by Bram Moolenaar Do ":help uganda"
+ * in Vim to read copying and usage conditions. Do ":help credits" in Vim to
+ * see a list of people who contributed. See README.txt for an overview of
+ * the Vim source code.
+ */
+#include "vim.h"
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include "jsapi.h"
+
+/* The class of the global object. */
+static JSClass global_class = {
+    "global", 
+    JSCLASS_GLOBAL_FLAGS,
+    JS_PropertyStub, 
+    JS_PropertyStub, 
+    JS_PropertyStub, 
+    JS_PropertyStub,
+    JS_EnumerateStub, 
+    JS_ResolveStub, 
+    JS_ConvertStub, 
+    JS_FinalizeStub,
+    JSCLASS_NO_OPTIONAL_MEMBERS
+};
+
+/* JS global variables. */
+JSRuntime *rt;
+JSContext *cx;
+JSObject  *global;
+
+
+/* The error reporter callback. */
+void reportError(JSContext *cx, const char *message, JSErrorReport *report)
+{
+    char *error_msg;
+    sprintf( error_msg , "Javascript Error: %s:%u:%s\n",
+            report->filename ? report->filename : "<no filename>",
+            (unsigned int) report->lineno,
+            message);
+
+    char *p;
+    p = strchr( error_msg , '\n');
+    if (p) *p = '\0';
+    MSG( error_msg );
+    return;
+}
+
+
+
+/* A wrapper for the system() function, from the C standard library. */
+JSBool js_system(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+    const char *cmd;
+    int rc;
+
+    if (!JS_ConvertArguments(cx, argc, argv, "s", &cmd))
+        return JS_FALSE;
+
+    rc = system(cmd);
+    if (rc != 0) {
+        /* Throw a JavaScript exception. */
+        JS_ReportError(cx, "Command failed with exit code %d", rc);
+        return JS_FALSE;
+    }
+
+    *rval = JSVAL_VOID;  /* return undefined */
+    return JS_TRUE;
+}
+
+JSBool js_vim_message(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+
+    const char *message;
+    if( !JS_ConvertArguments( cx , argc, argv , "s" , &message ) )
+        return JS_FALSE;
+
+    char *p;
+    p = strchr(message, '\n');
+    if (p) *p = '\0';
+    MSG(message);
+
+    *rval = JSVAL_VOID;
+    return JS_TRUE;
+}
+
+
+/* Export C functions to javascript environment. */
+static JSFunctionSpec js_global_functions[] = {
+    //JS_FS("rand",   js_rand,   0, 0, 0),
+    //JS_FS("srand",  js_srand,  0, 0, 0),
+    JS_FS("system"  , js_system      , 1 , 0 , 0) , 
+
+    /*  vim function interface here  */
+    JS_FS("alert"   , js_vim_message , 1 , 0 , 0) , 
+    JS_FS("message" , js_vim_message , 1 , 0 , 0) , 
+    JS_FS_END
+};
+
+
+/* :jsfile 
+ *
+ * @see: https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference/JS_CompileFile
+ * */
+    void
+ex_jsfile(exarg_T *eap)
+{
+    char *filename = (char *)eap->arg;
+    int compileOnly = 0;
+    JSScript *script = JS_CompileFile( cx,  global , filename );
+    if (script) {
+        if (!compileOnly)
+            (void)JS_ExecuteScript(cx, global , script, NULL);
+        JS_DestroyScript(cx, script);
+    }
+}
+
+
+
+void
+vim_js_init(arg)
+	char   *arg;
+{
+
+    /* Create a JS runtime. */
+    rt = JS_NewRuntime(8L * 1024L * 1024L);
+    if (rt == NULL)
+        return;
+
+    /* Create a context. */
+    cx = JS_NewContext(rt, 8192);
+    if (cx == NULL)
+        return;
+    JS_SetOptions(cx, JSOPTION_VAROBJFIX);
+    JS_SetVersion(cx, JSVERSION_LATEST);
+    JS_SetErrorReporter(cx, reportError);
+
+    /* Create the global object. */
+    global = JS_NewObject(cx, &global_class, NULL, NULL);
+    if (global == NULL)
+        return;
+
+    /* Populate the global object with the standard globals,
+       like Object and Array. */
+    if (!JS_InitStandardClasses(cx, global))
+        return;
+
+    if (!JS_DefineFunctions(cx, global, js_global_functions))
+        return;
+}
+
+void
+js_end()
+{
+
+    /* Cleanup. */
+    JS_DestroyContext(cx);
+    JS_DestroyRuntime(rt);
+    JS_ShutDown();
+
+}
Index: proto/if_js.pro
===================================================================
--- proto/if_js.pro	(revision 0)
+++ proto/if_js.pro	(revision 0)
@@ -0,0 +1,8 @@
+/* if_js.c */
+void vim_js_init __ARGS((char *arg));
+void js_end __ARGS((void));
+
+/* ex command */
+void ex_jsfile __ARGS((exarg_T *eap));
+
+/* vim: set ft=c : */
