Destroying jQuery Flot Graph

flot, jquery

Solution

If you read the API docs, there is a shutdown method that cleans up for you

shutdown()

Cleans up any event handlers Flot has currently registered. This
is used internally.

eg.

var plot = $.plot($("#yourDiv"), options)

plot.shutdown()

Problem

What is the correct way to destroy a jQuery flot graph in a way that will clean up all event handlers and not result in a memory leak? It seems flot is leaving behind some zombies (aka Detached Dom Trees)

Original source