I'm using billboard.js to display this type of chart somewhere below the fold of my page.
Adding the billboard JS code is causing my mobile page speed to decrease from 90+ to 75-80.
My code is structured like this:
<!-- chart area -->
<div class="chart_holder">
<div id="chart_area"></div>
</div>
...
...
...
<script src="/js/d3.v5.min.js"></script>
<script src="/js/billboard.min.js"></script>
<script defer src="/js/moment.min.js"></script>
<script type="text/javascript">function drawChart(t){$(".chart_holder").show(),.........);</script>
Is there any way to make the chart load later, in order to solve google page speed issues like:
- Reduce JavaScript execution time
Keep request counts low and transfer sizes small (Extra JS files are pretty big)
Minimize main-thread work (Script Evaluation)
While at the same time, allow Search engine crawlers to understand that I'm providing added value to my visitors by displaying them data charts? It might be good for SEO so I don't want to hide the chart in a way that google can't see it for example.
EDIT:
This is how the chart is called:
$(document).ready(function() {
$.ajax( {
type:"GET", url:"chart/data.php", dataType:"json", data: {
item_id: 'item'
}
, success:function(t) {
void 0!==t.criteria?t.criteria[0].length<=2?$(".chart_holder").hide(): drawChart(t): $(".chart_holder").hide()
}
, error:function() {
console.log("Data extraction failed")
}
}
)
}