diff options
author | Yukai Huang | 2016-10-11 17:15:06 +0800 |
---|---|---|
committer | Yukai Huang | 2016-10-11 17:15:06 +0800 |
commit | 56c5378939c6498d0440b3ed76a604523678073f (patch) | |
tree | a2ba61a6099a3192673687f22fb43bda2e198b5b /public/js | |
parent | d3315506dcb72ea4702842198d5c5c77549ed88b (diff) |
Optimize viz.js async rendering through webpack chunk
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/extra.js | 32 | ||||
-rw-r--r-- | public/js/index.js | 6 |
2 files changed, 18 insertions, 20 deletions
diff --git a/public/js/extra.js b/public/js/extra.js index 329aa153..e133a810 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -288,21 +288,25 @@ function finishView(view) { } }); //graphviz - var graphvizs = view.find(".graphviz.raw").removeClass("raw"); - graphvizs.each(function (key, value) { - try { - var $value = $(value); - var $ele = $(value).parent().parent(); - - var graphviz = Viz($value.text()); - $value.html(graphviz); + require.ensure(["viz.js"], function(require) { + var Viz = require("viz.js"); + var graphvizs = view.find(".graphviz.raw").removeClass("raw"); + graphvizs.each(function (key, value) { + try { + var $value = $(value); + var $ele = $(value).parent().parent(); + + var graphviz = Viz($value.text()); + $value.html(graphviz); + + $ele.addClass('graphviz'); + $value.children().unwrap().unwrap(); + } catch (err) { + console.warn(err); + } + }); - $ele.addClass('graphviz'); - $value.children().unwrap().unwrap(); - } catch (err) { - console.warn(err); - } - }); + }) //mermaid var mermaids = view.find(".mermaid.raw").removeClass("raw"); mermaids.each(function (key, value) { diff --git a/public/js/index.js b/public/js/index.js index 4bce2ff0..2d3c2965 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,9 +1,3 @@ -/* include jquery ui */ -require('jquery-ui/ui/widgets/resizable'); -require('jquery-ui/ui/widgets/tooltip'); -require('jquery-ui/ui/widgets/controlgroup'); -require('jquery-ui/ui/widgets/autocomplete'); - /* jquery and jquery plugins */ require('../vendor/showup/showup'); |