module AsyncHelper | |
def javascript_async(*args) | |
content_tag :script, type: "text/javascript" do | |
"(function() { | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.async = true; | |
script.src = '#{j javascript_path(*args)}'; | |
var other = document.getElementsByTagName('script')[0]; | |
other.parentNode.insertBefore(script, other); | |
})();".html_safe | |
end | |
end | |
end |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
PikachuEXE
commented
Nov 12, 2012
Thanks you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks you!
I used to do it in javascript way, but making it a helper is even better :D