These are chat archives for opal/opal

3rd
Oct 2016
Elia Schito
@elia
Oct 03 2016 08:29
@bwl21 are you using the javascript_include_tag helper?
Bernhard Weichel
@bwl21
Oct 03 2016 09:49

@elia yes, I do. Bu I have the problem with stuff that is loaded by other components. For example loading the language - mode in Ace, or the locale file in w2iui. I have no clue how these components do the loading. But when I try to load a resource by AJAX, I observer the same issue:

    $conf_helptext = {}
    HTTP.get("public/locale/conf-help_#{language}.json").then do |response|
      $conf_helptext = Native(response.body)
    end.fail do |response|
      alert "could not loaad confhelp #{response}"
    end.always do |response|
    end

when I change conf-help_de-de.json, I sometimes have to clear the browser cache to get the update.

Elia Schito
@elia
Oct 03 2016 09:56
@bwl21 you can try appending ?1234 to <script src tags, where 1234 would be the time stamp (as in Time.now.to_i)
in you example the address should become: "public/locale/conf-help_#{language}.json?#{Time.now.to_i}"
Bernhard Weichel
@bwl21
Oct 03 2016 09:58
I see. Thanks a lot, I will try this. I will raise an issue on cloud9/ace that they do the same, at least in debug mode.
Elia Schito
@elia
Oct 03 2016 10:00
@bwl21 btw the sprockets solutions is more hard core and embeds a digest of the file's contents in the file name (assets/app-dc756ad75ca5cd75dca.js) that's good for production, but for dev should be enought the ? trick
Bernhard Weichel
@bwl21
Oct 03 2016 10:01
but in this case, I should not have the problem as Opal server is based on sprockets
Elia Schito
@elia
Oct 03 2016 11:06
@bwl21 that's right as long as digest paths are used when building the paths, see https://github.com/rails/sprockets/blob/9db6aa1c8bec0c445c58d2783d7166f7c44a58f0/lib/sprockets/asset.rb#L61-L68
unfortunately there's not much more docs on that in sprockets, but here's the relevant rails guide: http://guides.rubyonrails.org/asset_pipeline.html#what-is-fingerprinting-and-why-should-i-care-questionmark
Forrest Chang
@fkchang
Oct 03 2016 17:54
Always good to keep an eye on the JS trends http://stateofjs.com/