score:7
If you just want to hide/show an object from time to time, then use jQuery .hide()
and .show()
. It's simplest and as long as you were going to keep the object around anyway, you may as well just use .hide()
and .show()
. Unless the object consumes massive amounts of memory, it shouldn't be an issue.
.remove()
(while saving and then reinserting the same object back in the DOM later) will be of little use to you because it destroys some of the data associated with the object so you may not be be able to easily reinsert it in the page.
.remove()
where you actually let the previous object gets destroyed by the garbage collector and then you recreate it from scratch when needed again is the most memory efficient operation, but unless it consumes a lot of memory or you have a lot of them (e.g. thousands), it's probably just more work to do it this way without any meaningful benefit.
.detach()
(while saving and then reinserting the same object back in the DOM later) will work, but it's more work than .hide()
and .show()
and, in all honesty, I rather doubt you will find a difference between the two options.
score:7
the 3 will trigger a render and redraw, hence, if performance is your concern, go for .hide(), as it will "spare" some dom manipulation (and potentially 2 redraw). Don't forget about listeners on your chart too.
However, i found that forperformance .addClass('hidden')
and .removeClass('hidden')
, with a css rule (.hidden {display: none}
) works best. (as long as you are not hidding on scrolling).
Source: stackoverflow.com
Related Query
- HighCharts : How to REMOVE (or) HIDE a certain data POINT in Series?
- Strange character in the Highstock source code
- ajax call does not fire jquery code
- Parsing JSON for use with Highcharts using jquery .parseJSON or JSON.parse: how to remove quotes from function calls for formatters?
- Highcharts in JQuery Tabs - Resizing hidden tab code stops resizing visible tab
- Dynamically changing Highcharts Theme through Jquery code not working
- dynamic data to Jquery code in ASP .Net Visual Studio
- How do I hide the code for the chart data in highcharts?
- HighCharts Hide Series Name from the Legend
- How to remove button from Highcharts
- Hide axis and gridlines Highcharts
- Proper way to remove all series data from a highcharts chart?
- how to hide highchart x - axis data values
- How to display the value instead of percentage in a pie chart using jquery Highcharts
- Hide line in default state in Highcharts
- How can I hide series from a HighCharts legend?
- Highchart - show / hide an y-Axis without hiding the series
- Remove shadow/background glow on highcharts data label?
- High charts remove dots from the line graph
- Highcharts jQuery rendering problem - all browsers
- highcharts hide zoom reset button, call zoom reset programmatically
- Remove Export and print button plugin on highchart chart
- remove grid line on chart
- How to hide labels in the highcharts in the pie
- Rounding results in highcharts jquery script
- How can I hide a series from initially being displayed in Highcharts
- Loading Highcharts via shim using RequireJS and maintaining jQuery dependency
- How to hide zero values in Column chart
- Highcharts: Hide and show legend
- HighStock : Remove Zoom bar
More Query from same tag
- .NET Highcharts not applying responsive rules
- Issue with highchart data display when parsing JSON data
- JSON date format for Highstocks
- How to embed solid Gauge using highcharts inside a div of a specific size
- Render Highcharts data table to separate container as chart via drawing API?
- Highcharts - is it possible to apply opacity for a specific zone?
- Highcharts with multiple series from JSON Dynamically
- Make Highcharts column chart bars as wide as mandated by a linear xaxis
- how to format flot char yaxis by value seconds in highcharts?
- Highcharts display label for pie chart using html table as data source
- Data is not getting displayed in PieChart of HighCharts using Angularjs (Dynamic Data from Ajax call)
- Setting color on label gridline Highcharts
- Highcharts live chart shifts continuously
- Moving highchart to the left when there is a Y-axis title
- Highcharts - curves goes outside the box
- Highcharts not referenced error when using setOptions
- HighCharts: Hide tooltip when value is zero when using 'split: true'
- Highcharts grouped bar charts with multiple axes
- Is it possible to give Highcharts, pie chart, an array of images instead of colors?
- Nested/multi-level/drill-down Pie Chart in Javascript?
- unable to Add display data values on top of bar high chart
- Highcharts library UI glitches
- Highcharts in R: sort xAxis in Line Chart
- Highcharts text labels for y-axis
- Hightchart x-axis to top
- How to show highchart graph depends on select tag from HTML
- Highcharts: Combined line and column chart - start / end line on left / right side, not on column chart data points
- How can I create Highcharts Arearange graph from CSV file?
- Highcharts & jQuery: add a mark by clicking with Shift key pressed, then process on release
- Could not make Highcharts display in pdf