styd / apexcharts.rb

:bar_chart: Awesome charts for your ruby app powered by ApexCharts.JS.
https://a-styd.gitbook.io/apexcharts-ruby/
MIT License
481 stars 29 forks source link

Add option to defer loading #58

Closed muriloime closed 4 years ago

muriloime commented 4 years ago

Hello, I added a very simple functionality to include an option defer to deferred charts.

It is defaulting to false for backward compatibility.

Cheers Murilo

styd commented 4 years ago

Hi, @muriloime . Thank you for your contributions. This is a good idea, but your implementation seems like the old way to do it. Can't we just use a defer attribute on the script tag? 98% of browsers already support it anyway. Or, do you have any concern with it?

muriloime commented 4 years ago

Hi @styd, after you said I tried to implement the defer tag, but it seems that it only works for external scripts (https://www.w3schools.com/tags/att_script_defer.asp ). So this approach (which is similar to chartkick) is the way to go IMO.

cheers

styd commented 4 years ago

Oh, you're right. How did I miss that. defer attribute is to defer loading a script, so of course it's for external files. Thank you.