A utility function to help in development of internal Javascript code, this function processes the Javascript to minify it and report on errors and bad style.

makeDependency(name, src, script = NULL, package, 
               version = packageVersion(package),
               minifile = paste0(basename(src), ".min.js"),
               debugging = FALSE, ...)


name, src, script, package, version, ...

Arguments to pass to htmltools::htmlDependency.


Basename of minified file.


See details below.


This is a utility function used by RGL to process its Javascript code used when displaying rglwidget values. It may be helpful in other packages to use in their own installation.

If the js package version 1.2 or greater is installed, the Javascript code will be minified and stored in the file named by minifile in the src directory. Syntax errors in the code will stop the process; unused variables will be reported.

If debugging is TRUE, the locations of Javascript syntax errors will be reported, along with hints about improvements, and the original files will be used in the dependency object that is created.

If debugging is FALSE (the default), the minified file will be used in the dependency object, hints won't be given, and syntax errors will lead to an uninformative failure to minify.


An object that can be included in a list of dependencies passed to htmltools::attachDependencies.


Duncan Murdoch


if (FALSE) {
# This is a slightly simplified version of the code used to 
# produce one of the dependencies for rglwidget().  
# It writes to the system library copy of rgl so 
# has been marked not to run in the example code.

               src = "htmlwidgets/lib/rglClass",
               script = c("rglClass.src.js",
               stylesheet = "rgl.css",
               package = "rgl",
               debugging = isTRUE(as.logical(Sys.getenv("RGL_DEBUGGING", "FALSE"))))